Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-06-23 03:26:45
Exec Total Coverage
Lines: 1750 4149 42.2%
Functions: 130 328 39.6%
Branches: 941 2694 34.9%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 #include "zc/zc_sys.h"
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 #include <math.h>
18 #include <map>
19 #include <filesystem>
20 #include <ctype.h>
21 #include <sstream>
22 #include "base/zc_alleg.h"
23 #include "gamedata.h"
24 #include "zc/zc_init.h"
25 #include "init.h"
26 #include "zc/replay.h"
27 #include "zc/cheats.h"
28 #include "zc/render.h"
29 #include "base/zc_math.h"
30 #include "base/zapp.h"
31 #include "dialog/cheatkeys.h"
32 #include "metadata/metadata.h"
33 #include "zc/zelda.h"
34 #include "tiles.h"
35 #include "base/colors.h"
36 #include "pal.h"
37 #include "base/zsys.h"
38 #include "qst.h"
39 #include "zc/zc_sys.h"
40 #include "play_midi.h"
41 #include "jwin_a5.h"
42 #include "base/jwinfsel.h"
43 #include "base/gui.h"
44 #include "midi.h"
45 #include "subscr.h"
46 #include "zc/maps.h"
47 #include "sprite.h"
48 #include "zc/guys.h"
49 #include "zc/hero.h"
50 #include "zc/title.h"
51 #include "particles.h"
52 #include "zconsole.h"
53 #include "zc/ffscript.h"
54 #include "dialog/info.h"
55 #include "dialog/alert.h"
56 #include "zc/combos.h"
57 #include <fmt/format.h>
58
59 #ifdef __EMSCRIPTEN__
60 #include "base/emscripten_utils.h"
61 #endif
62
63 extern FFScript FFCore;
64 extern bool Playing;
65 int32_t sfx_voice[WAV_COUNT];
66 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
67 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
68
69 extern byte monochrome_console;
70
71 extern HeroClass Hero;
72 extern FFScript FFCore;
73 extern ZModule zcm;
74 extern zcmodule moduledata;
75 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
76 extern particle_list particles;
77 extern int32_t loadlast;
78 extern word passive_subscreen_doscript;
79 extern bool passive_subscreen_waitdraw;
80 extern char *sfx_string[WAV_COUNT];
81 byte use_dwm_flush;
82 byte use_save_indicator;
83 byte midi_patch_fix;
84 bool midi_paused=false;
85 int32_t paused_midi_pos = 0;
86 byte midi_suspended = 0;
87 byte callback_switchin = 0;
88 byte zc_192b163_warp_compatibility;
89 char modulepath[2048];
90 bool epilepsyFlashReduction;
91 signed char pause_in_background_menu_init = 0;
92 byte pause_in_background = 0;
93 bool is_sys_pal = false;
94 static bool load_control_called_this_frame;
95 extern PALETTE* hw_palette;
96 extern bool update_hw_pal;
97 extern const char* dmaplist(int32_t index, int32_t* list_size);
98 int32_t getnumber(const char *prompt,int32_t initialval);
99
100 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
101 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
102 //extern byte refresh_select_screen;
103 //extern movingblock mblock2; //mblock[4]?
104 //extern int32_t db;
105
106 static const char *ZC_str = "Zelda Classic";
107 extern char save_file_name[1024];
108 #if defined(ALLEGRO_WINDOWS)
109 const char *qst_dir_name = "win_qst_dir";
110 static const char *qst_module_name = "current_module";
111 #elif defined(ALLEGRO_LINUX)
112 const char *qst_dir_name = "linux_qst_dir";
113 static const char *qst_module_name = "current_module";
114 #elif defined(__APPLE__)
115 const char *qst_dir_name = "osx_qst_dir";
116 static const char *qst_module_name = "current_module";
117 #endif
118 #ifdef ALLEGRO_LINUX
119 static const char *samplepath = "samplesoundset/patches.dat";
120 #endif
121 char qst_files_path[2048];
122
123 #ifdef _MSC_VER
124 #define getcwd _getcwd
125 #endif
126
127 bool rF11();
128 bool rI();
129 bool rQ();
130 bool zc_key_pressed();
131
132 #ifdef _WIN32
133
134 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
135 extern "C"
136 {
137 typedef HRESULT(WINAPI *t_DwmFlush)();
138 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
139 }
140
141 void do_DwmFlush()
142 {
143 static HMODULE shell = LoadLibrary("dwmapi.dll");
144
145 if(!shell)
146 return;
147
148 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
149 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
150
151 BOOL enabled;
152 isEnabled(&enabled);
153
154 if(isEnabled)
155 flush();
156 }
157
158 #endif // _WIN32
159
160 82835 bool flash_reduction_enabled(bool check_qr)
161 {
162
4/4
✓ Branch 0 taken 80614 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 80158 times.
✓ Branch 3 taken 82379 times.
82835 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
163 }
164
165 // Dialogue largening
166 void large_dialog(DIALOG *d)
167 {
168 large_dialog(d, 1.5);
169 }
170
171 void large_dialog(DIALOG *d, float RESIZE_AMT)
172 {
173 if(!d[0].d1)
174 {
175 d[0].d1 = 1;
176 int32_t oldwidth = d[0].w;
177 int32_t oldheight = d[0].h;
178 int32_t oldx = d[0].x;
179 int32_t oldy = d[0].y;
180 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
181 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
182 d[0].w = int32_t(d[0].w*RESIZE_AMT);
183 d[0].h = int32_t(d[0].h*RESIZE_AMT);
184
185 for(int32_t i=1; d[i].proc !=NULL; i++)
186 {
187 // Place elements horizontally
188 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
189 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
190
191 if(d[i].proc != d_stringloader)
192 {
193 if(d[i].proc==d_bitmap_proc)
194 {
195 d[i].w *= 2;
196 }
197 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
198 }
199
200 // Place elements vertically
201 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
202 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
203
204 // Vertically resize elements
205 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
206 {
207 d[i].h = int32_t((double)d[i].h*1.5);
208 }
209 else if(d[i].proc == jwin_droplist_proc)
210 {
211 d[i].y += int32_t((double)d[i].h*0.25);
212 d[i].h = int32_t((double)d[i].h*1.25);
213 }
214 else if(d[i].proc==d_bitmap_proc)
215 {
216 d[i].h *= 2;
217 }
218 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
219
220 // Fix frames
221 if(d[i].proc == jwin_frame_proc)
222 {
223 d[i].x++;
224 d[i].y++;
225 d[i].w-=4;
226 d[i].h-=4;
227 }
228 }
229 }
230
231 for(int32_t i=1; d[i].proc!=NULL; i++)
232 {
233 if(d[i].proc==jwin_slider_proc)
234 continue;
235
236 // Bigger font
237 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
238
239 if(!d[i].dp2 && bigfontproc)
240 {
241 d[i].dp2 = get_zc_font(font_lfont_l);
242 }
243 else if(!bigfontproc)
244 {
245 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
246 }
247
248 // Make checkboxes work
249 if(d[i].proc == jwin_check_proc)
250 d[i].proc = jwin_checkfont_proc;
251 else if(d[i].proc == jwin_radio_proc)
252 d[i].proc = jwin_radiofont_proc;
253 }
254
255 jwin_center_dialog(d);
256 }
257
258
259 /**********************************/
260 /******** System functions ********/
261 /**********************************/
262
263 static char cfg_sect[] = "zeldadx"; //We need to rename this.
264 static char ctrl_sect[] = "Controls";
265 static char sfx_sect[] = "Volume";
266
267 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
268 {
269 return D_O_K;
270 }
271
272 bool is_reserved_key(int c)
273 {
274 switch(c)
275 {
276 case KEY_ESC:
277 return true;
278 }
279 return false;
280 }
281 bool is_reserved_keycombo(int c, int modflag)
282 {
283 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
284 return true;
285 return false;
286 }
287 bool checkcheat(Cheat cheat)
288 {
289 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
290 return true; //Main key pressed
291 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
292 return true; //Alt key pressed
293 return false;
294 }
295 36 void load_default_cheatkeys()
296 {
297 36 memset(cheatkeys, 0, sizeof(cheatkeys));
298 36 cheatkeys[Cheat::Life][0] = KEY_H;
299 36 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
300 36 cheatkeys[Cheat::Magic][0] = KEY_M;
301 36 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
302 36 cheatkeys[Cheat::Rupies][0] = KEY_R;
303 36 cheatkeys[Cheat::Bombs][0] = KEY_B;
304 36 cheatkeys[Cheat::Arrows][0] = KEY_A;
305 36 cheatkeys[Cheat::Clock][0] = KEY_I;
306 36 cheatkeys[Cheat::Walls][0] = KEY_F11;
307 36 cheatkeys[Cheat::Fast][0] = KEY_Q;
308 36 cheatkeys[Cheat::Light][0] = KEY_L;
309 36 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
310 36 cheatkeys[Cheat::Kill][0] = KEY_K;
311 36 cheatkeys[Cheat::GoTo][0] = KEY_G;
312 36 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
313 36 cheatkeys[Cheat::ShowL0][0] = KEY_0;
314 36 cheatkeys[Cheat::ShowL1][0] = KEY_1;
315 36 cheatkeys[Cheat::ShowL2][0] = KEY_2;
316 36 cheatkeys[Cheat::ShowL3][0] = KEY_3;
317 36 cheatkeys[Cheat::ShowL4][0] = KEY_4;
318 36 cheatkeys[Cheat::ShowL5][0] = KEY_5;
319 36 cheatkeys[Cheat::ShowL6][0] = KEY_6;
320 36 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
321 36 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
322 36 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
323 36 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
324 36 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
325 36 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
326 36 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
327 36 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
328 36 }
329 36 void load_game_configs()
330 {
331 36 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
332 36 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
333 36 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
334 36 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
335 36 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
336 36 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
337 36 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
338 36 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
339 36 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
340 36 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
341 36 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
342 36 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
343 36 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
344 36 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
345 36 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
346
347 //cheat modifier keya
348 36 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
349 36 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
350 36 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
351 36 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
352
353 //cheat keys
354 36 load_default_cheatkeys();
355 char buf[256];
356
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 36 times.
1296 for(size_t q = 1; q < Cheat::Last; ++q)
357 {
358
1/2
✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
1260 if(!bindable_cheat((Cheat)q)) continue;
359 1260 std::string cheatname = cheat_to_string((Cheat)q);
360
1/2
✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
1260 util::lowerstr(cheatname);
361 1260 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
362
1/2
✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
1260 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
363 1260 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
364
1/2
✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
1260 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
365 1260 }
366
367
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
368 joystick_index = 0;
369
370 36 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
371 36 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
372 36 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
373 36 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
374 36 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
375 36 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
376 36 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
377 36 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
378 36 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
379 36 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
380
381 36 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
382 36 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
383 36 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
384 36 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
385
386 36 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
387 36 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
388 36 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
389 36 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
390 36 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
391 36 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
392 36 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
393 36 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
394 36 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
395 36 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
396 36 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
397
398 36 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
399 36 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
400 36 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
401 36 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
402
403 36 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
404
405 36 digi_volume = zc_get_config(sfx_sect,"digi",248);
406 36 midi_volume = zc_get_config(sfx_sect,"midi",255);
407 36 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
408 36 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
409 36 pan_style = zc_get_config(sfx_sect,"pan",1);
410 // 1 <= zcmusic_bufsz <= 128
411 36 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
412 36 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
413 36 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
414 36 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
415 36 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
416 36 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
417 36 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
418 #ifdef __EMSCRIPTEN__
419 if (em_is_mobile()) NameEntryMode = 2;
420 #endif
421 36 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
422 36 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
423 36 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
424 36 title_version = zc_get_config(cfg_sect,"title",2);
425 36 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
426 36 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
427
428 //default - scale x2, 640 x 480
429 36 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
430 36 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
431 36 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
432 36 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
433 36 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
434 36 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
435 36 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
436
437 36 loadlast = zc_get_config(cfg_sect,"load_last",0);
438
439 36 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
440
441 36 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
442
443 36 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
444 36 info_opacity = zc_get_config("zc","debug_info_opacity",255);
445 #ifdef _WIN32
446 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
447 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
448 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
449 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
450
451 // This one's for Aero
452 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
453
454 // And this one fixes patches unloading on some MIDI setups
455 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
456 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
457 #else //UNIX
458 36 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
459 36 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
460 36 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
461 #endif
462 36 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
463 36 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
464
465 36 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
466
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(strlen(qstdir)==0)
468 {
469 36 getcwd(qstdir,2048);
470 36 fix_filename_case(qstdir);
471 36 fix_filename_slashes(qstdir);
472 36 put_backslash(qstdir);
473 36 }
474 else
475 {
476 chop_path(qstdir);
477 }
478
479 36 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
480 36 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
481 36 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
482 36 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
483 36 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
484 36 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
485 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
486 36 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
487 36 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
488 36 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
489 36 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
490 36 }
491
492 void save_control_configs(bool kb)
493 {
494 if(kb)
495 {
496 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
497 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
498 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
499 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
500
501 if (!replay_is_replaying())
502 {
503 zc_set_config(ctrl_sect,"key_a",Akey);
504 zc_set_config(ctrl_sect,"key_b",Bkey);
505 zc_set_config(ctrl_sect,"key_s",Skey);
506 zc_set_config(ctrl_sect,"key_l",Lkey);
507 zc_set_config(ctrl_sect,"key_r",Rkey);
508 zc_set_config(ctrl_sect,"key_p",Pkey);
509 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
510 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
511 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
512 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
513 zc_set_config(ctrl_sect,"key_up", DUkey);
514 zc_set_config(ctrl_sect,"key_down", DDkey);
515 zc_set_config(ctrl_sect,"key_left", DLkey);
516 zc_set_config(ctrl_sect,"key_right",DRkey);
517 }
518 }
519 else
520 {
521 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
522 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
523 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
524 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
525 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
526 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
527 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
528 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
529 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
530 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
531 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
532 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
533 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
534 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
535
536 zc_set_config(ctrl_sect,"btn_a",Abtn);
537 zc_set_config(ctrl_sect,"btn_b",Bbtn);
538 zc_set_config(ctrl_sect,"btn_s",Sbtn);
539 zc_set_config(ctrl_sect,"btn_m",Mbtn);
540 zc_set_config(ctrl_sect,"btn_l",Lbtn);
541 zc_set_config(ctrl_sect,"btn_r",Rbtn);
542 zc_set_config(ctrl_sect,"btn_p",Pbtn);
543 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
544 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
545 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
546 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
547
548 zc_set_config(ctrl_sect,"btn_up",DUbtn);
549 zc_set_config(ctrl_sect,"btn_down",DDbtn);
550 zc_set_config(ctrl_sect,"btn_left",DLbtn);
551 zc_set_config(ctrl_sect,"btn_right",DRbtn);
552 }
553 }
554
555 void save_cheatkeys()
556 {
557 char buf[256];
558 for(size_t q = 1; q < Cheat::Last; ++q)
559 {
560 if(!bindable_cheat((Cheat)q)) continue;
561 std::string cheatname = cheat_to_string((Cheat)q);
562 util::lowerstr(cheatname);
563 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
564 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
565 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
566 if(cheatkeys[q][1])
567 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
568 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
569 }
570 }
571
572 void save_game_configs()
573 {
574 packfile_password("");
575
576 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
577
578 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
579 {
580 int o_window_x, o_window_y;
581 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
582 zc_set_config(cfg_sect,"window_x",o_window_x);
583 zc_set_config(cfg_sect,"window_y",o_window_y);
584 }
585
586 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
587 {
588 double monitor_scale = zc_get_monitor_scale();
589 window_width = al_get_display_width(all_get_display()) / monitor_scale;
590 window_height = al_get_display_height(all_get_display()) / monitor_scale;
591 zc_set_config(cfg_sect,"window_width",window_width);
592 zc_set_config(cfg_sect,"window_height",window_height);
593 }
594
595 zc_set_config(cfg_sect,"load_last",loadlast);
596 chop_path(qstdir);
597 zc_set_config(cfg_sect,qst_dir_name,qstdir);
598 zc_set_config("SAVEFILE","save_filename",save_file_name);
599 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
600
601 flush_config_file();
602 #ifdef __EMSCRIPTEN__
603 em_sync_fs();
604 #endif
605 }
606
607 //----------------------------------------------------------------
608
609 // Timers
610
611 32561 void fps_callback()
612 {
613 32561 lastfps=framecnt;
614 32561 dword tempsecs = fps_secs;
615 32561 ++tempsecs;
616 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
617 32561 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
618 32561 ++fps_secs;
619 32561 framecnt=0;
620 32561 }
621
622 END_OF_FUNCTION(fps_callback)
623
624 36 int32_t Z_init_timers()
625 {
626 static bool didit = false;
627 const static char *err_str = "Couldn't allocate timer";
628 36 err_str = err_str; //Unused variable warning
629
630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(didit)
631 return 1;
632
633 36 didit = true;
634
635 LOCK_VARIABLE(lastfps);
636 LOCK_VARIABLE(framecnt);
637 LOCK_FUNCTION(fps_callback);
638
639
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
640 return 0;
641
642 36 return 1;
643 36 }
644
645 void Z_remove_timers()
646 {
647 remove_int(fps_callback);
648 }
649
650 //----------------------------------------------------------------
651
652 void go()
653 {
654 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
655 }
656
657 void comeback()
658 {
659 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
660 }
661
662 void dump_pal(BITMAP *dest)
663 {
664 for(int32_t i=0; i<256; i++)
665 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
666 }
667
668 //----------------------------------------------------------------
669
670 int game_mouse_index = ZCM_BLANK;
671 static bool system_mouse = false;
672 98 bool sys_mouse()
673 {
674 98 system_mouse = true;
675 98 return MouseSprite::set(ZCM_NORMAL);
676 }
677 463 bool game_mouse()
678 {
679 463 system_mouse = false;
680 463 return MouseSprite::set(game_mouse_index);
681 }
682 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
683 {
684 if(!bmp)
685 return;
686 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
687 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
688 if(bmp->w == scaledw && bmp->h == scaledh)
689 user_scale = false;
690 if(user_scale || sys_recolor)
691 {
692 if(!user_scale) scale = 1;
693 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
694 if(user_scale)
695 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
696 else
697 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
698 if(sys_recolor)
699 recolor_mouse(tmpbmp);
700 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
701 destroy_bitmap(tmpbmp);
702 }
703 else
704 {
705 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
706 }
707 }
708
709 //Handles converting the mouse sprite from the .dat file
710 36 void recolor_mouse(BITMAP* bmp)
711 {
712
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 36 times.
612 for(int32_t x = 0; x < bmp->w; ++x)
713 {
714
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 576 times.
9792 for(int32_t y = 0; y < bmp->h; ++y)
715 {
716 9216 int32_t color = getpixel(bmp, x, y);
717
5/5
✓ Branch 0 taken 6264 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 792 times.
✓ Branch 3 taken 828 times.
✓ Branch 4 taken 648 times.
9216 switch(color)
718 {
719 case dvc(1):
720 684 color = jwin_pal[jcCURSORMISC];
721 684 break;
722 case dvc(2):
723 792 color = jwin_pal[jcCURSOROUTLINE];
724 792 break;
725 case dvc(3):
726 828 color = jwin_pal[jcCURSORLIGHT];
727 828 break;
728 case dvc(5):
729 648 color = jwin_pal[jcCURSORDARK];
730 648 break;
731 default:
732 6264 continue;
733 }
734 2952 putpixel(bmp, x, y, color);
735 2952 }
736 576 }
737 36 }
738 36 void load_mouse()
739 {
740 36 enter_sys_pal();
741 36 MouseSprite::set(-1);
742 36 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
743 36 int32_t sz = 16*scale;
744
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 36 times.
72 for(int32_t j = 0; j < 1; ++j)
745 {
746 36 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
747
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(zcmouse[j])
748 destroy_bitmap(zcmouse[j]);
749 36 zcmouse[j] = create_bitmap_ex(8,sz,sz);
750 36 clear_bitmap(zcmouse[j]);
751 36 clear_bitmap(tmpbmp);
752 36 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
753 36 recolor_mouse(tmpbmp);
754
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(sz!=16)
755 36 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
756 else
757 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
758 36 destroy_bitmap(tmpbmp);
759 36 }
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!hw_palette) hw_palette = &RAMpal;
761 36 zc_set_palette(*hw_palette);
762
763 36 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
764 36 clear_bitmap(blankmouse);
765
766 36 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
767 36 MouseSprite::assign(ZCM_BLANK, blankmouse);
768 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
769
770 //Reload the mouse
771
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(system_mouse)
772 36 sys_mouse();
773 else game_mouse();
774
775 36 destroy_bitmap(blankmouse);
776 36 exit_sys_pal();
777 36 }
778
779 // sets the video mode and initializes the palette and mouse sprite
780 36 bool game_vid_mode(int32_t mode,int32_t wait)
781 {
782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
783 {
784 return false;
785 }
786
787 36 scrx = (resx-320)>>1;
788 36 scry = (resy-240)>>1;
789
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 36 times.
72 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
790 36 zcmouse[q] = NULL;
791 36 load_mouse();
792
793
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 36 times.
612 for(int32_t i=240; i<256; i++)
794 576 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
795
796 36 zc_set_palette(RAMpal);
797 36 clear_to_color(screen,BLACK);
798
799 36 rest(wait);
800 36 return true;
801 36 }
802
803 8 void null_quest()
804 {
805 char qstdat_string[2048];
806 8 strcpy(qstdat_string, "modules/classic/default.qst");
807
808 #ifdef __EMSCRIPTEN__
809 // The quest template data file is not included because it's really big and isn't really needed
810 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
811 // which is much smaller.
812 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
813 #endif
814
815 8 byte skip_flags[4] = { 0 };
816
817 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,skip_flags,0,false);
818 8 }
819
820 // TODO remove
821 8 void init_NES_mode()
822 {
823 8 null_quest();
824 8 }
825
826 //----------------------------------------------------------------
827
828 qword trianglelines[16]=
829 {
830 0x0000000000000000ULL,
831 0xFD00000000000000ULL,
832 0xFDFD000000000000ULL,
833 0xFDFDFD0000000000ULL,
834 0xFDFDFDFD00000000ULL,
835 0xFDFDFDFDFD000000ULL,
836 0xFDFDFDFDFDFD0000ULL,
837 0xFDFDFDFDFDFDFD00ULL,
838 0xFDFDFDFDFDFDFDFDULL,
839 0x00FDFDFDFDFDFDFDULL,
840 0x0000FDFDFDFDFDFDULL,
841 0x000000FDFDFDFDFDULL,
842 0x00000000FDFDFDFDULL,
843 0x0000000000FDFDFDULL,
844 0x000000000000FDFDULL,
845 0x00000000000000FDULL,
846 };
847
848 word screen_triangles[28][32];
849 /*
850 qword triangles[4][16]= //[direction][value]
851 {
852 {
853 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
854 },
855 {
856 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
857 },
858 {
859 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
860 },
861 {
862 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
863 }
864 };
865 */
866
867
868 /*
869 byte triangles[4][16][8]= //[direction][value][line]
870 {
871 {
872 {
873 0, 0, 0, 0, 0, 0, 0, 0
874 },
875 {
876 1, 0, 0, 0, 0, 0, 0, 0
877 },
878 {
879 2, 1, 0, 0, 0, 0, 0, 0
880 },
881 {
882 3, 2, 1, 0, 0, 0, 0, 0
883 },
884 {
885 4, 3, 2, 1, 0, 0, 0, 0
886 },
887 {
888 5, 4, 3, 2, 1, 0, 0, 0
889 },
890 {
891 6, 5, 4, 3, 2, 1, 0, 0
892 },
893 {
894 7, 6, 5, 4, 3, 2, 1, 0
895 },
896 {
897 8, 7, 6, 5, 4, 3, 2, 1
898 },
899 {
900 8, 8, 7, 6, 5, 4, 3, 2
901 },
902 {
903 8, 8, 8, 7, 6, 5, 4, 3
904 },
905 {
906 8, 8, 8, 8, 7, 6, 5, 4
907 },
908 {
909 8, 8, 8, 8, 8, 7, 6, 5
910 },
911 {
912 8, 8, 8, 8, 8, 8, 7, 6
913 },
914 {
915 8, 8, 8, 8, 8, 8, 8, 7
916 },
917 {
918 8, 8, 8, 8, 8, 8, 8, 8
919 }
920 },
921 {
922 {
923 0, 0, 0, 0, 0, 0, 0, 0
924 },
925 {
926 15, 0, 0, 0, 0, 0, 0, 0
927 },
928 {
929 14, 15, 0, 0, 0, 0, 0, 0
930 },
931 {
932 13, 14, 15, 0, 0, 0, 0, 0
933 },
934 {
935 12, 13, 14, 15, 0, 0, 0, 0
936 },
937 {
938 11, 12, 13, 14, 15, 0, 0, 0
939 },
940 {
941 10, 11, 12, 13, 14, 15, 0, 0
942 },
943 {
944 9, 10, 11, 12, 13, 14, 15, 0
945 },
946 {
947 8, 9, 10, 11, 12, 13, 14, 15
948 },
949 {
950 8, 8, 9, 10, 11, 12, 13, 14
951 },
952 {
953 8, 8, 8, 9, 10, 11, 12, 13
954 },
955 {
956 8, 8, 8, 8, 9, 10, 11, 12
957 },
958 {
959 8, 8, 8, 8, 8, 9, 10, 11
960 },
961 {
962 8, 8, 8, 8, 8, 8, 9, 10
963 },
964 {
965 8, 8, 8, 8, 8, 8, 8, 9
966 },
967 {
968 8, 8, 8, 8, 8, 8, 8, 8
969 }
970 },
971 {
972 {
973 0, 0, 0, 0, 0, 0, 0, 0
974 },
975 {
976 0, 0, 0, 0, 0, 0, 0, 1
977 },
978 {
979 0, 0, 0, 0, 0, 0, 1, 2
980 },
981 {
982 0, 0, 0, 0, 0, 1, 2, 3
983 },
984 {
985 0, 0, 0, 0, 1, 2, 3, 4
986 },
987 {
988 0, 0, 0, 1, 2, 3, 4, 5
989 },
990 {
991 0, 0, 1, 2, 3, 4, 5, 6
992 },
993 {
994 0, 1, 2, 3, 4, 5, 6, 7
995 },
996 {
997 1, 2, 3, 4, 5, 6, 7, 8
998 },
999 {
1000 2, 3, 4, 5, 6, 7, 8, 8
1001 },
1002 {
1003 3, 4, 5, 6, 7, 8, 8, 8
1004 },
1005 {
1006 4, 5, 6, 7, 8, 8, 8, 8
1007 },
1008 {
1009 5, 6, 7, 8, 8, 8, 8, 8
1010 },
1011 {
1012 6, 7, 8, 8, 8, 8, 8, 8
1013 },
1014 {
1015 7, 8, 8, 8, 8, 8, 8, 8
1016 },
1017 {
1018 8, 8, 8, 8, 8, 8, 8, 8
1019 }
1020 },
1021 {
1022 {
1023 0, 0, 0, 0, 0, 0, 0, 0
1024 },
1025 {
1026 0, 0, 0, 0, 0, 0, 0, 15
1027 },
1028 {
1029 0, 0, 0, 0, 0, 0, 15, 14
1030 },
1031 {
1032 0, 0, 0, 0, 0, 15, 14, 13
1033 },
1034 {
1035 0, 0, 0, 0, 15, 14, 13, 12
1036 },
1037 {
1038 0, 0, 0, 15, 14, 13, 12, 11
1039 },
1040 {
1041 0, 0, 15, 14, 13, 12, 11, 10
1042 },
1043 {
1044 0, 15, 14, 13, 12, 11, 10, 9
1045 },
1046 {
1047 15, 14, 13, 12, 11, 10, 9, 8
1048 },
1049 {
1050 14, 13, 12, 11, 10, 9, 8, 8
1051 },
1052 {
1053 13, 12, 11, 10, 9, 8, 8, 8
1054 },
1055 {
1056 12, 11, 10, 9, 8, 8, 8, 8
1057 },
1058 {
1059 11, 10, 9, 8, 8, 8, 8, 8
1060 },
1061 {
1062 10, 9, 8, 8, 8, 8, 8, 8
1063 },
1064 {
1065 9, 8, 8, 8, 8, 8, 8, 8
1066 },
1067 {
1068 8, 8, 8, 8, 8, 8, 8, 8
1069 }
1070 }
1071 };
1072 */
1073
1074
1075
1076 /*
1077 for (int32_t blockrow=0; blockrow<30; ++i)
1078 {
1079 for (int32_t linerow=0; linerow<8; ++i)
1080 {
1081 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1082 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1083 {
1084 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1085 ++triangleline;
1086 }
1087 }
1088 }
1089 */
1090
1091 // the ULL suffixes are to prevent this warning:
1092 // warning: integer constant is too large for "int32_t" type
1093
1094 qword triangles[4][16][8]= //[direction][value][line]
1095 {
1096 {
1097 {
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL
1106 },
1107 {
1108 0xFD00000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL
1116 },
1117 {
1118 0xFDFD000000000000ULL,
1119 0xFD00000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL
1126 },
1127 {
1128 0xFDFDFD0000000000ULL,
1129 0xFDFD000000000000ULL,
1130 0xFD00000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL
1136 },
1137 {
1138 0xFDFDFDFD00000000ULL,
1139 0xFDFDFD0000000000ULL,
1140 0xFDFD000000000000ULL,
1141 0xFD00000000000000ULL,
1142 0x0000000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL
1146 },
1147 {
1148 0xFDFDFDFDFD000000ULL,
1149 0xFDFDFDFD00000000ULL,
1150 0xFDFDFD0000000000ULL,
1151 0xFDFD000000000000ULL,
1152 0xFD00000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL
1156 },
1157 {
1158 0xFDFDFDFDFDFD0000ULL,
1159 0xFDFDFDFDFD000000ULL,
1160 0xFDFDFDFD00000000ULL,
1161 0xFDFDFD0000000000ULL,
1162 0xFDFD000000000000ULL,
1163 0xFD00000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL
1166 },
1167 {
1168 0xFDFDFDFDFDFDFD00ULL,
1169 0xFDFDFDFDFDFD0000ULL,
1170 0xFDFDFDFDFD000000ULL,
1171 0xFDFDFDFD00000000ULL,
1172 0xFDFDFD0000000000ULL,
1173 0xFDFD000000000000ULL,
1174 0xFD00000000000000ULL,
1175 0x0000000000000000ULL
1176 },
1177 {
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFD00ULL,
1180 0xFDFDFDFDFDFD0000ULL,
1181 0xFDFDFDFDFD000000ULL,
1182 0xFDFDFDFD00000000ULL,
1183 0xFDFDFD0000000000ULL,
1184 0xFDFD000000000000ULL,
1185 0xFD00000000000000ULL
1186 },
1187 {
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFD00ULL,
1191 0xFDFDFDFDFDFD0000ULL,
1192 0xFDFDFDFDFD000000ULL,
1193 0xFDFDFDFD00000000ULL,
1194 0xFDFDFD0000000000ULL,
1195 0xFDFD000000000000ULL
1196 },
1197 {
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFD00ULL,
1202 0xFDFDFDFDFDFD0000ULL,
1203 0xFDFDFDFDFD000000ULL,
1204 0xFDFDFDFD00000000ULL,
1205 0xFDFDFD0000000000ULL
1206 },
1207 {
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFD00ULL,
1213 0xFDFDFDFDFDFD0000ULL,
1214 0xFDFDFDFDFD000000ULL,
1215 0xFDFDFDFD00000000ULL
1216 },
1217 {
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFD00ULL,
1224 0xFDFDFDFDFDFD0000ULL,
1225 0xFDFDFDFDFD000000ULL
1226 },
1227 {
1228 0xFDFDFDFDFDFDFDFDULL,
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFD00ULL,
1235 0xFDFDFDFDFDFD0000ULL
1236 },
1237 {
1238 0xFDFDFDFDFDFDFDFDULL,
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFD00ULL
1246 },
1247 {
1248 0xFDFDFDFDFDFDFDFDULL,
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL
1256 }
1257 },
1258 {
1259 {
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL
1268 },
1269 {
1270 0x00000000000000FDULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL
1278 },
1279 {
1280 0x000000000000FDFDULL,
1281 0x00000000000000FDULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL
1288 },
1289 {
1290 0x0000000000FDFDFDULL,
1291 0x000000000000FDFDULL,
1292 0x00000000000000FDULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL
1298 },
1299 {
1300 0x00000000FDFDFDFDULL,
1301 0x0000000000FDFDFDULL,
1302 0x000000000000FDFDULL,
1303 0x00000000000000FDULL,
1304 0x0000000000000000ULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL
1308 },
1309 {
1310 0x000000FDFDFDFDFDULL,
1311 0x00000000FDFDFDFDULL,
1312 0x0000000000FDFDFDULL,
1313 0x000000000000FDFDULL,
1314 0x00000000000000FDULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL
1318 },
1319 {
1320 0x0000FDFDFDFDFDFDULL,
1321 0x000000FDFDFDFDFDULL,
1322 0x00000000FDFDFDFDULL,
1323 0x0000000000FDFDFDULL,
1324 0x000000000000FDFDULL,
1325 0x00000000000000FDULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL
1328 },
1329 {
1330 0x00FDFDFDFDFDFDFDULL,
1331 0x0000FDFDFDFDFDFDULL,
1332 0x000000FDFDFDFDFDULL,
1333 0x00000000FDFDFDFDULL,
1334 0x0000000000FDFDFDULL,
1335 0x000000000000FDFDULL,
1336 0x00000000000000FDULL,
1337 0x0000000000000000ULL
1338 },
1339 {
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0x00FDFDFDFDFDFDFDULL,
1342 0x0000FDFDFDFDFDFDULL,
1343 0x000000FDFDFDFDFDULL,
1344 0x00000000FDFDFDFDULL,
1345 0x0000000000FDFDFDULL,
1346 0x000000000000FDFDULL,
1347 0x00000000000000FDULL
1348 },
1349 {
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0x00FDFDFDFDFDFDFDULL,
1353 0x0000FDFDFDFDFDFDULL,
1354 0x000000FDFDFDFDFDULL,
1355 0x00000000FDFDFDFDULL,
1356 0x0000000000FDFDFDULL,
1357 0x000000000000FDFDULL
1358 },
1359 {
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0x00FDFDFDFDFDFDFDULL,
1364 0x0000FDFDFDFDFDFDULL,
1365 0x000000FDFDFDFDFDULL,
1366 0x00000000FDFDFDFDULL,
1367 0x0000000000FDFDFDULL
1368 },
1369 {
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0x00FDFDFDFDFDFDFDULL,
1375 0x0000FDFDFDFDFDFDULL,
1376 0x000000FDFDFDFDFDULL,
1377 0x00000000FDFDFDFDULL
1378 },
1379 {
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0x00FDFDFDFDFDFDFDULL,
1386 0x0000FDFDFDFDFDFDULL,
1387 0x000000FDFDFDFDFDULL
1388 },
1389 {
1390 0xFDFDFDFDFDFDFDFDULL,
1391 0xFDFDFDFDFDFDFDFDULL,
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0x00FDFDFDFDFDFDFDULL,
1397 0x0000FDFDFDFDFDFDULL
1398 },
1399 {
1400 0xFDFDFDFDFDFDFDFDULL,
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0x00FDFDFDFDFDFDFDULL
1408 },
1409 {
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL,
1417 0xFDFDFDFDFDFDFDFDULL
1418 }
1419 },
1420 {
1421 {
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0x0000000000000000ULL
1430 },
1431 {
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0x0000000000000000ULL,
1439 0xFD00000000000000ULL
1440 },
1441 {
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0x0000000000000000ULL,
1448 0xFD00000000000000ULL,
1449 0xFDFD000000000000ULL
1450 },
1451 {
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0x0000000000000000ULL,
1457 0xFD00000000000000ULL,
1458 0xFDFD000000000000ULL,
1459 0xFDFDFD0000000000ULL
1460 },
1461 {
1462 0x0000000000000000ULL,
1463 0x0000000000000000ULL,
1464 0x0000000000000000ULL,
1465 0x0000000000000000ULL,
1466 0xFD00000000000000ULL,
1467 0xFDFD000000000000ULL,
1468 0xFDFDFD0000000000ULL,
1469 0xFDFDFDFD00000000ULL
1470 },
1471 {
1472 0x0000000000000000ULL,
1473 0x0000000000000000ULL,
1474 0x0000000000000000ULL,
1475 0xFD00000000000000ULL,
1476 0xFDFD000000000000ULL,
1477 0xFDFDFD0000000000ULL,
1478 0xFDFDFDFD00000000ULL,
1479 0xFDFDFDFDFD000000ULL
1480 },
1481 {
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL,
1484 0xFD00000000000000ULL,
1485 0xFDFD000000000000ULL,
1486 0xFDFDFD0000000000ULL,
1487 0xFDFDFDFD00000000ULL,
1488 0xFDFDFDFDFD000000ULL,
1489 0xFDFDFDFDFDFD0000ULL
1490 },
1491 {
1492 0x0000000000000000ULL,
1493 0xFD00000000000000ULL,
1494 0xFDFD000000000000ULL,
1495 0xFDFDFD0000000000ULL,
1496 0xFDFDFDFD00000000ULL,
1497 0xFDFDFDFDFD000000ULL,
1498 0xFDFDFDFDFDFD0000ULL,
1499 0xFDFDFDFDFDFDFD00ULL
1500 },
1501 {
1502 0xFD00000000000000ULL,
1503 0xFDFD000000000000ULL,
1504 0xFDFDFD0000000000ULL,
1505 0xFDFDFDFD00000000ULL,
1506 0xFDFDFDFDFD000000ULL,
1507 0xFDFDFDFDFDFD0000ULL,
1508 0xFDFDFDFDFDFDFD00ULL,
1509 0xFDFDFDFDFDFDFDFDULL
1510 },
1511 {
1512 0xFDFD000000000000ULL,
1513 0xFDFDFD0000000000ULL,
1514 0xFDFDFDFD00000000ULL,
1515 0xFDFDFDFDFD000000ULL,
1516 0xFDFDFDFDFDFD0000ULL,
1517 0xFDFDFDFDFDFDFD00ULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL
1520 },
1521 {
1522 0xFDFDFD0000000000ULL,
1523 0xFDFDFDFD00000000ULL,
1524 0xFDFDFDFDFD000000ULL,
1525 0xFDFDFDFDFDFD0000ULL,
1526 0xFDFDFDFDFDFDFD00ULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL
1530 },
1531 {
1532 0xFDFDFDFD00000000ULL,
1533 0xFDFDFDFDFD000000ULL,
1534 0xFDFDFDFDFDFD0000ULL,
1535 0xFDFDFDFDFDFDFD00ULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL
1540 },
1541 {
1542 0xFDFDFDFDFD000000ULL,
1543 0xFDFDFDFDFDFD0000ULL,
1544 0xFDFDFDFDFDFDFD00ULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL
1550 },
1551 {
1552 0xFDFDFDFDFDFD0000ULL,
1553 0xFDFDFDFDFDFDFD00ULL,
1554 0xFDFDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL,
1559 0xFDFDFDFDFDFDFDFDULL
1560 },
1561 {
1562 0xFDFDFDFDFDFDFD00ULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL,
1569 0xFDFDFDFDFDFDFDFDULL
1570 },
1571 {
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL,
1579 0xFDFDFDFDFDFDFDFDULL
1580 }
1581 },
1582 {
1583 {
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x0000000000000000ULL
1592 },
1593 {
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x0000000000000000ULL,
1601 0x00000000000000FDULL
1602 },
1603 {
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x0000000000000000ULL,
1610 0x00000000000000FDULL,
1611 0x000000000000FDFDULL
1612 },
1613 {
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x0000000000000000ULL,
1619 0x00000000000000FDULL,
1620 0x000000000000FDFDULL,
1621 0x0000000000FDFDFDULL
1622 },
1623 {
1624 0x0000000000000000ULL,
1625 0x0000000000000000ULL,
1626 0x0000000000000000ULL,
1627 0x0000000000000000ULL,
1628 0x00000000000000FDULL,
1629 0x000000000000FDFDULL,
1630 0x0000000000FDFDFDULL,
1631 0x00000000FDFDFDFDULL
1632 },
1633 {
1634 0x0000000000000000ULL,
1635 0x0000000000000000ULL,
1636 0x0000000000000000ULL,
1637 0x00000000000000FDULL,
1638 0x000000000000FDFDULL,
1639 0x0000000000FDFDFDULL,
1640 0x00000000FDFDFDFDULL,
1641 0x000000FDFDFDFDFDULL
1642 },
1643 {
1644 0x0000000000000000ULL,
1645 0x0000000000000000ULL,
1646 0x00000000000000FDULL,
1647 0x000000000000FDFDULL,
1648 0x0000000000FDFDFDULL,
1649 0x00000000FDFDFDFDULL,
1650 0x000000FDFDFDFDFDULL,
1651 0x0000FDFDFDFDFDFDULL
1652 },
1653 {
1654 0x0000000000000000ULL,
1655 0x00000000000000FDULL,
1656 0x000000000000FDFDULL,
1657 0x0000000000FDFDFDULL,
1658 0x00000000FDFDFDFDULL,
1659 0x000000FDFDFDFDFDULL,
1660 0x0000FDFDFDFDFDFDULL,
1661 0x00FDFDFDFDFDFDFDULL
1662 },
1663 {
1664 0x00000000000000FDULL,
1665 0x000000000000FDFDULL,
1666 0x0000000000FDFDFDULL,
1667 0x00000000FDFDFDFDULL,
1668 0x000000FDFDFDFDFDULL,
1669 0x0000FDFDFDFDFDFDULL,
1670 0x00FDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL
1672 },
1673 {
1674 0x000000000000FDFDULL,
1675 0x0000000000FDFDFDULL,
1676 0x00000000FDFDFDFDULL,
1677 0x000000FDFDFDFDFDULL,
1678 0x0000FDFDFDFDFDFDULL,
1679 0x00FDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL
1682 },
1683 {
1684 0x0000000000FDFDFDULL,
1685 0x00000000FDFDFDFDULL,
1686 0x000000FDFDFDFDFDULL,
1687 0x0000FDFDFDFDFDFDULL,
1688 0x00FDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL
1692 },
1693 {
1694 0x00000000FDFDFDFDULL,
1695 0x000000FDFDFDFDFDULL,
1696 0x0000FDFDFDFDFDFDULL,
1697 0x00FDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL
1702 },
1703 {
1704 0x000000FDFDFDFDFDULL,
1705 0x0000FDFDFDFDFDFDULL,
1706 0x00FDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL
1712 },
1713 {
1714 0x0000FDFDFDFDFDFDULL,
1715 0x00FDFDFDFDFDFDFDULL,
1716 0xFDFDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL,
1721 0xFDFDFDFDFDFDFDFDULL
1722 },
1723 {
1724 0x00FDFDFDFDFDFDFDULL,
1725 0xFDFDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL,
1731 0xFDFDFDFDFDFDFDFDULL
1732 },
1733 {
1734 0xFDFDFDFDFDFDFDFDULL,
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL,
1741 0xFDFDFDFDFDFDFDFDULL
1742 }
1743 }
1744 };
1745
1746 int32_t black_opening_count=0;
1747 int32_t black_opening_x,black_opening_y;
1748 int32_t black_opening_shape;
1749
1750 1133 int32_t choose_opening_shape()
1751 {
1752 // First, count how many bits are set
1753 1133 int32_t numBits=0;
1754 int32_t bitCounter;
1755
1756
2/2
✓ Branch 0 taken 5665 times.
✓ Branch 1 taken 1133 times.
6798 for(int32_t i=0; i<bosMAX; i++)
1757 {
1758
2/2
✓ Branch 0 taken 4316 times.
✓ Branch 1 taken 1349 times.
5665 if(COOLSCROLL&(1<<i))
1759 1349 numBits++;
1760 5665 }
1761
1762 // Shouldn't happen...
1763
1/2
✓ Branch 0 taken 1133 times.
✗ Branch 1 not taken.
1133 if(numBits==0)
1764 return bosCIRCLE;
1765
1766 // Pick a bit
1767 1133 bitCounter=zc_rand()%numBits+1;
1768
1769
2/2
✓ Branch 0 taken 1399 times.
✓ Branch 1 taken 26 times.
1425 for(int32_t i=0; i<bosMAX; i++)
1770 {
1771 // If this bit is set, decrement the bit counter
1772
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1263 times.
1399 if(COOLSCROLL&(1<<i))
1773 1263 bitCounter--;
1774
1775 // When the counter hits 0, return a value based on
1776 // which bit it stopped on.
1777 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1778
2/2
✓ Branch 0 taken 1107 times.
✓ Branch 1 taken 292 times.
1399 if(bitCounter==0)
1779 1107 return i;
1780 292 }
1781
1782 // Shouldn't be necessary, but the compiler might complain, at least
1783 26 return bosCIRCLE;
1784 1133 }
1785
1786 311 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1787 {
1788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311 times.
311 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1789
1790 311 int32_t w=256, h=224;
1791 311 int32_t blockrows=28, blockcolumns=32;
1792 311 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1793
1794
2/2
✓ Branch 0 taken 8708 times.
✓ Branch 1 taken 311 times.
9019 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1795 {
1796
2/2
✓ Branch 0 taken 278656 times.
✓ Branch 1 taken 8708 times.
287364 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1797 {
1798
2/2
✓ Branch 0 taken 148380 times.
✓ Branch 1 taken 130276 times.
278656 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1799 278656 }
1800 8708 }
1801
1802 311 black_opening_count = 66;
1803 311 black_opening_x = x;
1804 311 black_opening_y = y;
1805 311 lensclk = 0;
1806 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1807
1808
1809
1/2
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
311 if(black_opening_shape == bosFADEBLACK)
1810 {
1811 refreshTints();
1812 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1813 }
1814
1/2
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
311 if(wait)
1815 {
1816 FFCore.warpScriptCheck();
1817 for(int32_t i=0; i<66; i++)
1818 {
1819 draw_screen(tmpscr);
1820 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1821 advanceframe(true);
1822
1823 if(Quit)
1824 {
1825 break;
1826 }
1827 }
1828 }
1829 311 }
1830
1831 822 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1832 {
1833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 822 times.
822 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1834
1835 822 int32_t w=256, h=224;
1836 822 int32_t blockrows=28, blockcolumns=32;
1837 822 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1838
1839
2/2
✓ Branch 0 taken 23016 times.
✓ Branch 1 taken 822 times.
23838 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1840 {
1841
2/2
✓ Branch 0 taken 736512 times.
✓ Branch 1 taken 23016 times.
759528 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1842 {
1843
2/2
✓ Branch 0 taken 334699 times.
✓ Branch 1 taken 401813 times.
736512 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1844 736512 }
1845 23016 }
1846
1847 822 black_opening_count = -66;
1848 822 black_opening_x = x;
1849 822 black_opening_y = y;
1850 822 lensclk = 0;
1851
1/2
✓ Branch 0 taken 822 times.
✗ Branch 1 not taken.
822 if(black_opening_shape == bosFADEBLACK)
1852 {
1853 refreshTints();
1854 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1855 }
1856
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 627 times.
822 if(wait)
1857 {
1858 627 FFCore.warpScriptCheck();
1859
2/2
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 41382 times.
42009 for(int32_t i=0; i<66; i++)
1860 {
1861 41382 draw_screen(tmpscr);
1862 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1863 41382 advanceframe(true);
1864
1865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41382 times.
41382 if(Quit)
1866 {
1867 break;
1868 }
1869 41382 }
1870 627 }
1871 822 }
1872
1873 74778 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1874 {
1875 74778 clear_to_color(tmp_scr,BLACK);
1876 74778 int32_t w=256, h=224;
1877
1878
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 2838 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70422 times.
74778 switch(black_opening_shape)
1879 {
1880 case bosOVAL:
1881 {
1882 858 double new_w=(w/2)+abs(w/2-x);
1883 858 double new_h=(h/2)+abs(h/2-y);
1884 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1885 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1886 858 break;
1887 }
1888
1889 case bosTRIANGLE:
1890 {
1891 660 double new_w=(w/2)+abs(w/2-x);
1892 660 double new_h=(h/2)+abs(h/2-y);
1893 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1894 660 double P2= (PI/2);
1895 660 double P23=(2*PI/3);
1896 660 double P43=(4*PI/3);
1897 660 double Pa= (-4*PI*a/(3*max_a));
1898 660 double angle=P2+Pa;
1899 660 double a0=angle;
1900 660 double a2=angle+P23;
1901 660 double a4=angle+P43;
1902 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1903 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1904 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1905 0);
1906 660 break;
1907 }
1908
1909 case bosSMAS:
1910 {
1911
2/2
✓ Branch 0 taken 1452 times.
✓ Branch 1 taken 1386 times.
2838 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1912
1913
2/2
✓ Branch 0 taken 79464 times.
✓ Branch 1 taken 2838 times.
82302 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1914 {
1915
2/2
✓ Branch 0 taken 635712 times.
✓ Branch 1 taken 79464 times.
715176 for(int32_t linerow=0; linerow<8; ++linerow)
1916 {
1917 635712 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1918
1919
2/2
✓ Branch 0 taken 20342784 times.
✓ Branch 1 taken 635712 times.
20978496 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1920 {
1921 61028352 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1922
6/6
✓ Branch 0 taken 14117840 times.
✓ Branch 1 taken 6224944 times.
✓ Branch 2 taken 13330568 times.
✓ Branch 3 taken 7012216 times.
✓ Branch 4 taken 7105624 times.
✓ Branch 5 taken 6224944 times.
20342784 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1923 20342784 [linerow];
1924 20342784 ++triangleline;
1925
1926
2/2
✓ Branch 0 taken 17799936 times.
✓ Branch 1 taken 2542848 times.
20342784 if(linerow==0)
1927 {
1928 2542848 }
1929 20342784 }
1930 635712 }
1931 79464 }
1932
1933 2838 break;
1934 }
1935
1936 case bosFADEBLACK:
1937 {
1938 if(black_opening_count<0)
1939 {
1940 black_fade(zc_min(-black_opening_count,63));
1941 }
1942 else if(black_opening_count>0)
1943 {
1944 black_fade(63-zc_max(black_opening_count-3,0));
1945 }
1946 else black_fade(0);
1947 return; //no blitting from tmp_scr!
1948 }
1949
1950 70422 case bosCIRCLE:
1951 default:
1952 {
1953 70422 double new_w=(w/2)+abs(w/2-x);
1954 70422 double new_h=(h/2)+abs(h/2-y);
1955 70422 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1956 //circlefill(tmp_scr,x,y,a<<3,0);
1957 70422 circlefill(tmp_scr,x,y,r,0);
1958 70422 break;
1959 }
1960 }
1961
1962 74778 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1963 74778 }
1964
1965
1966 void black_fade(int32_t fadeamnt)
1967 {
1968 for(int32_t i=0; i < 0xEF; i++)
1969 {
1970 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1971 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1972 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1973 }
1974
1975 refreshpal = true;
1976 }
1977
1978 //----------------------------------------------------------------
1979
1980 32847726 bool item_disabled(int32_t item) //is this item disabled?
1981 {
1982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32847726 times.
32847726 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1983 }
1984
1985 6700512 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1986 {
1987
2/2
✓ Branch 0 taken 80417 times.
✓ Branch 1 taken 6620095 times.
6700512 if(current_item(item_type, true) >=item)
1988 {
1989 80417 return true;
1990 }
1991
1992 6620095 return false;
1993 6700512 }
1994
1995 27643526 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1996 {
1997
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5062550 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3051917 times.
✓ Branch 6 taken 14691074 times.
✓ Branch 7 taken 4803305 times.
✓ Branch 8 taken 34680 times.
27643526 switch(item_type)
1998 {
1999 case itype_bomb:
2000 case itype_sbomb:
2001 {
2002 int32_t itemid = getItemID(itemsbuf, item_type, it);
2003
2004 if(itemid == -1)
2005 return false;
2006
2007 return (game->get_item(itemid));
2008 }
2009
2010 case itype_clock:
2011 {
2012 5062550 int32_t itemid = getItemID(itemsbuf, item_type, it);
2013
2014
2/4
✓ Branch 0 taken 5062550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5062550 times.
✗ Branch 3 not taken.
5062550 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2015 return (game->get_item(itemid));
2016 5062550 return Hero.getClock()?1:0;
2017 }
2018
2019 case itype_key:
2020 return (game->get_keys()>0);
2021
2022 case itype_magiccontainer:
2023 return (game->get_maxmagic()>=game->get_mp_per_block());
2024
2025 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2026 {
2027
1/3
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3051917 switch(it)
2028 {
2029 case -2:
2030 {
2031 for(int32_t i=0; i<MAXLEVELS; i++)
2032 {
2033 if(game->lvlitems[i]&liTRIFORCE)
2034 {
2035 return true;
2036 }
2037 }
2038
2039 return false;
2040 }
2041
2042 case -1:
2043 return (game->lvlitems[dlevel]&liTRIFORCE);
2044
2045 default:
2046
2/4
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3051917 times.
3051917 if(it>=0&&it<MAXLEVELS)
2047 {
2048 3051917 return (game->lvlitems[it]&liTRIFORCE);
2049 }
2050
2051 break;
2052 }
2053
2054 return 0;
2055 }
2056
2057 case itype_map: //it: -2=any, -1=current level, other=that level
2058 {
2059
1/3
✓ Branch 0 taken 14691074 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
14691074 switch(it)
2060 {
2061 case -2:
2062 {
2063 for(int32_t i=0; i<MAXLEVELS; i++)
2064 {
2065 if(game->lvlitems[i]&liMAP)
2066 {
2067 return true;
2068 }
2069 }
2070
2071 return false;
2072 }
2073
2074 case -1:
2075 return (game->lvlitems[dlevel]&liMAP)!=0;
2076
2077 default:
2078
2/4
✓ Branch 0 taken 14691074 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14691074 times.
14691074 if(it>=0&&it<MAXLEVELS)
2079 {
2080 14691074 return (game->lvlitems[it]&liMAP)!=0;
2081 }
2082
2083 break;
2084 }
2085
2086 return 0;
2087 }
2088
2089 case itype_compass: //it: -2=any, -1=current level, other=that level
2090 {
2091
1/3
✓ Branch 0 taken 4803305 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
4803305 switch(it)
2092 {
2093 case -2:
2094 {
2095 for(int32_t i=0; i<MAXLEVELS; i++)
2096 {
2097 if(game->lvlitems[i]&liCOMPASS)
2098 {
2099 return true;
2100 }
2101 }
2102
2103 return false;
2104 }
2105
2106 case -1:
2107 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2108
2109 default:
2110
2/4
✓ Branch 0 taken 4803305 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4803305 times.
✗ Branch 3 not taken.
4803305 if(it>=0&&it<MAXLEVELS)
2111 {
2112 4803305 return (game->lvlitems[it]&liCOMPASS)!=0;
2113 }
2114
2115 break;
2116 }
2117 return 0;
2118 }
2119
2120 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2121 {
2122
1/3
✓ Branch 0 taken 34680 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
34680 switch(it)
2123 {
2124 case -2:
2125 {
2126 for(int32_t i=0; i<MAXLEVELS; i++)
2127 {
2128 if(game->lvlitems[i]&liBOSSKEY)
2129 {
2130 return true;
2131 }
2132 }
2133
2134 return false;
2135 }
2136
2137 case -1:
2138 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2139
2140 default:
2141
2/4
✓ Branch 0 taken 34680 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34680 times.
34680 if(it>=0&&it<MAXLEVELS)
2142 {
2143 34680 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2144 }
2145 break;
2146 }
2147 return 0;
2148 }
2149
2150 default:
2151 //it=(1<<(it-1));
2152 /*if (item_type>=itype_max)
2153 {
2154 enter_sys_pal();
2155 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2156 exit_sys_pal();
2157
2158 return false;
2159 }*/
2160 int32_t itemid = getItemID(itemsbuf, item_type, it);
2161
2162 if(itemid == -1)
2163 return false;
2164
2165 return game->get_item(itemid);
2166 }
2167 27643526 }
2168
2169
2170 86375540 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2171 {
2172
9/9
✓ Branch 0 taken 5062550 times.
✓ Branch 1 taken 45875140 times.
✓ Branch 2 taken 5062550 times.
✓ Branch 3 taken 5062550 times.
✓ Branch 4 taken 5062550 times.
✓ Branch 5 taken 5062550 times.
✓ Branch 6 taken 5062550 times.
✓ Branch 7 taken 5062550 times.
✓ Branch 8 taken 5062550 times.
86375540 switch(item_type)
2173 {
2174 case itype_clock:
2175 {
2176 5062550 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2177
2178
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5062550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5062550 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2179 return itemsbuf[maxid].fam_type;
2180
2181 5062550 return has_item(itype_clock,1) ? 1 : 0;
2182 }
2183
2184 case itype_key:
2185 5062550 return game->get_keys();
2186
2187 case itype_lkey:
2188 5062550 return game->lvlkeys[get_dlevel()];
2189
2190 case itype_magiccontainer:
2191 5062550 return game->get_maxmagic()/game->get_mp_per_block();
2192
2193 case itype_triforcepiece:
2194 {
2195 5062550 int32_t count=0;
2196
2197
2/2
✓ Branch 0 taken 2592025600 times.
✓ Branch 1 taken 5062550 times.
2597088150 for(int32_t i=0; i<MAXLEVELS; i++)
2198 {
2199 2592025600 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2200 2592025600 }
2201
2202 5062550 return count;
2203 }
2204
2205 case itype_map:
2206 {
2207 5062550 int32_t count=0;
2208
2209
2/2
✓ Branch 0 taken 2592025600 times.
✓ Branch 1 taken 5062550 times.
2597088150 for(int32_t i=0; i<MAXLEVELS; i++)
2210 {
2211 2592025600 count+=(game->lvlitems[i]&liMAP)?1:0;
2212 2592025600 }
2213
2214 5062550 return count;
2215 }
2216
2217 case itype_compass:
2218 {
2219 5062550 int32_t count=0;
2220
2221
2/2
✓ Branch 0 taken 2592025600 times.
✓ Branch 1 taken 5062550 times.
2597088150 for(int32_t i=0; i<MAXLEVELS; i++)
2222 {
2223 2592025600 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2224 2592025600 }
2225
2226 5062550 return count;
2227 }
2228
2229 case itype_bosskey:
2230 {
2231 5062550 int32_t count=0;
2232
2233
2/2
✓ Branch 0 taken 2592025600 times.
✓ Branch 1 taken 5062550 times.
2597088150 for(int32_t i=0; i<MAXLEVELS; i++)
2234 {
2235 2592025600 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2236 2592025600 }
2237
2238 5062550 return count;
2239 }
2240
2241 default:
2242 45875140 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2243
2244
2/2
✓ Branch 0 taken 8708400 times.
✓ Branch 1 taken 37166740 times.
45875140 if(maxid == -1)
2245 37166740 return 0;
2246
2247 8708400 return itemsbuf[maxid].fam_type;
2248 }
2249 86375540 }
2250
2251 79675028 int32_t current_item(int32_t item_type) //item currently being used
2252 {
2253 79675028 return current_item(item_type, true);
2254 }
2255
2256 36 std::map<int32_t, int32_t> itemcache;
2257
2258 // Not actually used by anything at the moment...
2259 void removeFromItemCache(int32_t itemclass)
2260 {
2261 itemcache.erase(itemclass);
2262 }
2263
2264 24260 void flushItemCache()
2265 {
2266 24260 itemcache.clear();
2267
2268 //also fix the active subscreen if items were deleted -DD
2269
1/2
✓ Branch 0 taken 24260 times.
✗ Branch 1 not taken.
24260 if(game != NULL)
2270 {
2271 24260 verifyBothWeapons();
2272 24260 load_Sitems(&QMisc);
2273 24260 }
2274 24260 }
2275
2276 // This is used often, so it should be as direct as possible.
2277 2821871974 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2278 {
2279
2/2
✓ Branch 0 taken 2763492204 times.
✓ Branch 1 taken 58379770 times.
2821871974 if(jinx_check)
2280 {
2281
4/4
✓ Branch 0 taken 38218568 times.
✓ Branch 1 taken 20161202 times.
✓ Branch 2 taken 34554904 times.
✓ Branch 3 taken 3663664 times.
58379770 if(!(HeroSwordClk() || HeroItemClk()))
2282 34554904 jinx_check = false; //not jinxed
2283 58379770 }
2284
4/4
✓ Branch 0 taken 2797756808 times.
✓ Branch 1 taken 24115166 times.
✓ Branch 2 taken 23650363 times.
✓ Branch 3 taken 2774106445 times.
2821871974 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2285 {
2286 2774106445 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2287
2288
2/2
✓ Branch 0 taken 2761720874 times.
✓ Branch 1 taken 12385571 times.
2774106445 if(res != itemcache.end())
2289 2761720874 return res->second;
2290 12385571 }
2291
2292 60151100 int32_t result = -1;
2293 60151100 int32_t highestlevel = -1;
2294
2295
2/2
✓ Branch 0 taken 15398681600 times.
✓ Branch 1 taken 60151100 times.
15458832700 for(int32_t i=0; i<MAXITEMS; i++)
2296 {
2297
5/6
✓ Branch 0 taken 1197624245 times.
✓ Branch 1 taken 14201057355 times.
✓ Branch 2 taken 17819077 times.
✓ Branch 3 taken 1179805168 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17819077 times.
15398681600 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2298 {
2299
4/4
✓ Branch 0 taken 5189582 times.
✓ Branch 1 taken 12629495 times.
✓ Branch 2 taken 1358129 times.
✓ Branch 3 taken 16460948 times.
17819077 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2300 {
2301 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2302
2/2
✓ Branch 0 taken 16460791 times.
✓ Branch 1 taken 157 times.
16460948 if(!checkmagiccost(i))
2303 {
2304
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 145 times.
157 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2305 12 }
2306 16460803 }
2307
6/6
✓ Branch 0 taken 15432346 times.
✓ Branch 1 taken 2386586 times.
✓ Branch 2 taken 256688 times.
✓ Branch 3 taken 2129898 times.
✓ Branch 4 taken 1627257 times.
✓ Branch 5 taken 759329 times.
17818932 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2308 {
2309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 759329 times.
759329 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2310 759329 continue;
2311 }
2312
2313
2/2
✓ Branch 0 taken 237659 times.
✓ Branch 1 taken 16821944 times.
17059603 if(itemsbuf[i].fam_type >= highestlevel)
2314 {
2315 16821944 highestlevel = itemsbuf[i].fam_type;
2316 16821944 result=i;
2317 16821944 }
2318 17059603 }
2319 15397922126 }
2320
2321
2/2
✓ Branch 0 taken 23824866 times.
✓ Branch 1 taken 36326234 times.
60151100 if(!jinx_check) //Can't cache jinx_check results
2322 36326234 itemcache[itemtype] = result;
2323 60151100 return result;
2324 2821871974 }
2325
2326 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2327 2798364554 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2328 {
2329 2798364554 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2330
2/2
✓ Branch 0 taken 34872350 times.
✓ Branch 1 taken 2763492204 times.
2798364554 if(!jinx_check) //If not already a jinx-immune-only check...
2331 {
2332 //And the player IS jinxed...
2333
4/4
✓ Branch 0 taken 2743596586 times.
✓ Branch 1 taken 19895618 times.
✓ Branch 2 taken 3611802 times.
✓ Branch 3 taken 2739984784 times.
2763492204 if(HeroSwordClk() || HeroItemClk())
2334 {
2335 //Then do a jinx-immune-only check here
2336 23507420 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2337 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2338 //Should NOT need a compat rule, as this should always return -1 in old quests.
2339
2/2
✓ Branch 0 taken 1102644 times.
✓ Branch 1 taken 22404776 times.
23507420 if(ret2 > -1) return ret2;
2340 22404776 }
2341 2762389560 }
2342 2797261910 return ret;
2343 2798364554 }
2344 17620980 int32_t current_item_power(int32_t itemtype)
2345 {
2346 17620980 int32_t result = current_item_id(itemtype,true);
2347
2/2
✓ Branch 0 taken 13112274 times.
✓ Branch 1 taken 4508706 times.
17620980 return (result<0) ? 0 : itemsbuf[result].power;
2348 }
2349
2350 7 int32_t heart_container_id()
2351 {
2352
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2353 {
2354
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2355 {
2356 7 return i;
2357 }
2358 196 }
2359 return -1;
2360 7 }
2361
2362 5062550 int32_t item_tile_mod()
2363 {
2364 5062550 int32_t tile=0;
2365
2366
2/2
✓ Branch 0 taken 1051507 times.
✓ Branch 1 taken 4011043 times.
5062550 if(game->get_bombs())
2367 {
2368 4011043 int32_t itemid = current_item_id(itype_bomb,false);
2369
3/4
✓ Branch 0 taken 3929984 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3929984 times.
4011043 if(itemid > -1 && checkbunny(itemid))
2370 3929984 tile+=itemsbuf[itemid].ltm;
2371 4011043 }
2372
2373
2/2
✓ Branch 0 taken 3892116 times.
✓ Branch 1 taken 1170434 times.
5062550 if(game->get_sbombs())
2374 {
2375 1170434 int32_t itemid = current_item_id(itype_sbomb,false);
2376
3/4
✓ Branch 0 taken 1169006 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1169006 times.
1170434 if(itemid > -1 && checkbunny(itemid))
2377 1169006 tile+=itemsbuf[itemid].ltm;
2378 1170434 }
2379
2380
2/2
✓ Branch 0 taken 4958607 times.
✓ Branch 1 taken 103943 times.
5062550 if(current_item(itype_clock))
2381 {
2382 103943 int32_t itemid =
2383
1/2
✓ Branch 0 taken 103943 times.
✗ Branch 1 not taken.
103943 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2384 ? iClock
2385 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2386
2/4
✓ Branch 0 taken 103943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103943 times.
103943 if(itemid > -1 && checkbunny(itemid))
2387 103943 tile+=itemsbuf[itemid].ltm;
2388 103943 }
2389
2390
2/2
✓ Branch 0 taken 4016638 times.
✓ Branch 1 taken 1045912 times.
5062550 if(current_item(itype_key))
2391 {
2392 1045912 int32_t itemid =
2393
1/2
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
1045912 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2394 ? iKey
2395 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2396
2/4
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1045912 times.
1045912 if(itemid > -1 && checkbunny(itemid))
2397 1045912 tile+=itemsbuf[itemid].ltm;
2398 1045912 }
2399
2400
2/2
✓ Branch 0 taken 4890019 times.
✓ Branch 1 taken 172531 times.
5062550 if(current_item(itype_lkey))
2401 {
2402 172531 int32_t itemid =
2403
2/2
✓ Branch 0 taken 171621 times.
✓ Branch 1 taken 910 times.
172531 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2404 ? iLevelKey
2405 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2406
2/4
✓ Branch 0 taken 172531 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 172531 times.
172531 if(itemid > -1 && checkbunny(itemid))
2407 172531 tile+=itemsbuf[itemid].ltm;
2408 172531 }
2409
2410
2/2
✓ Branch 0 taken 1027074 times.
✓ Branch 1 taken 4035476 times.
5062550 if(current_item(itype_map))
2411 {
2412 4035476 int32_t itemid =
2413
2/2
✓ Branch 0 taken 4034690 times.
✓ Branch 1 taken 786 times.
4035476 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2414 ? iMap
2415 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2416
2/4
✓ Branch 0 taken 4035476 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4035476 times.
4035476 if(itemid > -1 && checkbunny(itemid))
2417 4035476 tile+=itemsbuf[itemid].ltm;
2418 4035476 }
2419
2420
2/2
✓ Branch 0 taken 1005192 times.
✓ Branch 1 taken 4057358 times.
5062550 if(current_item(itype_compass))
2421 {
2422 4057358 int32_t itemid =
2423
2/2
✓ Branch 0 taken 3976299 times.
✓ Branch 1 taken 81059 times.
4057358 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2424 ? iCompass
2425 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2426
2/4
✓ Branch 0 taken 4057358 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4057358 times.
4057358 if(itemid > -1 && checkbunny(itemid))
2427 4057358 tile+=itemsbuf[itemid].ltm;
2428 4057358 }
2429
2430
2/2
✓ Branch 0 taken 3193346 times.
✓ Branch 1 taken 1869204 times.
5062550 if(current_item(itype_bosskey))
2431 {
2432 1869204 int32_t itemid =
2433
1/2
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
1869204 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2434 ? iBossKey
2435 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2436
2/4
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1869204 times.
1869204 if(itemid > -1 && checkbunny(itemid))
2437 1869204 tile+=itemsbuf[itemid].ltm;
2438 1869204 }
2439
2440
2/2
✓ Branch 0 taken 2907435 times.
✓ Branch 1 taken 2155115 times.
5062550 if(current_item(itype_magiccontainer))
2441 {
2442 2155115 int32_t itemid =
2443
2/2
✓ Branch 0 taken 2062128 times.
✓ Branch 1 taken 92987 times.
2155115 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2444 ? iMagicC
2445 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2446
3/4
✓ Branch 0 taken 2155115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 2153245 times.
2155115 if(itemid > -1 && checkbunny(itemid))
2447 2153245 tile+=itemsbuf[itemid].ltm;
2448 2155115 }
2449
2450
2/2
✓ Branch 0 taken 1363257 times.
✓ Branch 1 taken 3699293 times.
5062550 if(current_item(itype_triforcepiece))
2451 {
2452 3699293 int32_t itemid =
2453
1/2
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
3699293 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2454 ? iTriforce
2455 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2456
2/4
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3699293 times.
3699293 if(itemid > -1 && checkbunny(itemid))
2457 3699293 tile+=itemsbuf[itemid].ltm;
2458 3699293 }
2459
2460
2/2
✓ Branch 0 taken 5062550 times.
✓ Branch 1 taken 2592025600 times.
2597088150 for(int32_t i=0; i<itype_max; i++)
2461 {
2462
2/2
✓ Branch 0 taken 2540776448 times.
✓ Branch 1 taken 51249152 times.
2592025600 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2463 {
2464
2/2
✓ Branch 0 taken 1000960 times.
✓ Branch 1 taken 50248192 times.
51249152 switch(i)
2465 {
2466 case itype_bomb:
2467 case itype_sbomb:
2468 case itype_clock:
2469 case itype_key:
2470 case itype_lkey:
2471 case itype_map:
2472 case itype_compass:
2473 case itype_bosskey:
2474 case itype_magiccontainer:
2475 case itype_triforcepiece:
2476 1000960 continue; //already handled
2477 }
2478 50248192 }
2479 2591024640 int32_t itemid = current_item_id(i,false);
2480
2/2
✓ Branch 0 taken 2585962090 times.
✓ Branch 1 taken 5062550 times.
2591024640 if(i == itype_shield)
2481 5062550 itemid = getCurrentShield(false);
2482
2483
4/4
✓ Branch 0 taken 70896404 times.
✓ Branch 1 taken 2520128236 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 70795423 times.
2591024640 if(itemid < 0 || !checkbunny(itemid))
2484 2520229217 continue;
2485
2486 70795423 itemdata const& itm = itemsbuf[itemid];
2487
2488
2/2
✓ Branch 0 taken 66346546 times.
✓ Branch 1 taken 4448877 times.
70795423 switch(itm.family)
2489 {
2490 case itype_shield:
2491
1/2
✓ Branch 0 taken 4448877 times.
✗ Branch 1 not taken.
4448877 if(itm.flags & ITEM_FLAG9) //active shield
2492 {
2493 if(!usingActiveShield(itemid))
2494 {
2495 tile+=itm.misc6; //'Inactive PTM'
2496 continue;
2497 }
2498 }
2499 4448877 break;
2500 }
2501
2502 70795423 tile+=itm.ltm;
2503 70795423 }
2504
2505 5062550 return tile;
2506 }
2507
2508 5062550 int32_t bunny_tile_mod()
2509 {
2510
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 5060680 times.
5062550 if(Hero.BunnyClock())
2511 {
2512 1870 return game->get_bunny_ltm();
2513 }
2514 5060680 return 0;
2515 5062550 }
2516
2517 // Hints are drawn on a separate layer to combo reveals.
2518 16332 void draw_lens_under(BITMAP *dest, bool layer)
2519 {
2520 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2521 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2522 //Lens flag 3: Don't show armos/chest/dive items
2523 //Lens flag 4: Show Raft Paths
2524 //Lens flag 5: Show Invisible Enemies
2525
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2526
2527 16332 int32_t strike_hint_table[11]=
2528 {
2529 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2530 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2531 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2532 };
2533
2534 // int32_t page = tmpscr->cpage;
2535 {
2536 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2537 // int32_t temptimer=0;
2538 16332 int32_t tempitem, tempweapon=0;
2539 16332 strike_hint=strike_hint_table[strike_hint_counter];
2540
2541
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2542 {
2543 492 strike_hint_timer=0;
2544 492 strike_hint_counter=((strike_hint_counter+1)%11);
2545 492 }
2546
2547 16332 ++strike_hint_timer;
2548
2549
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2550 {
2551 2874432 int32_t x = (i & 15) << 4;
2552 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2553 2874432 int32_t tempitemx=-16, tempitemy=-16;
2554 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2555
2556
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2557 {
2558 5748864 int32_t checkflag=0;
2559
2560
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2561 {
2562 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2563 2874432 }
2564 else
2565 {
2566 2874432 checkflag=tmpscr->sflag[i];
2567 }
2568
2569
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2570 {
2571
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2572 {
2573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2574 906 }
2575 else
2576 {
2577 192 checkflag = strike_hint;
2578 }
2579 1098 }
2580
2581
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2582 {
2583 case 0:
2584 case mfZELDA:
2585 case mfPUSHED:
2586 case mfENEMY0:
2587 case mfENEMY1:
2588 case mfENEMY2:
2589 case mfENEMY3:
2590 case mfENEMY4:
2591 case mfENEMY5:
2592 case mfENEMY6:
2593 case mfENEMY7:
2594 case mfENEMY8:
2595 case mfENEMY9:
2596 case mfSINGLE:
2597 case mfSINGLE16:
2598 case mfNOENEMY:
2599 case mfTRAP_H:
2600 case mfTRAP_V:
2601 case mfTRAP_4:
2602 case mfTRAP_LR:
2603 case mfTRAP_UD:
2604 case mfNOGROUNDENEMY:
2605 case mfNOBLOCKS:
2606 case mfSCRIPT1:
2607 case mfSCRIPT2:
2608 case mfSCRIPT3:
2609 case mfSCRIPT4:
2610 case mfSCRIPT5:
2611 case mfSCRIPT6:
2612 case mfSCRIPT7:
2613 case mfSCRIPT8:
2614 case mfSCRIPT9:
2615 case mfSCRIPT10:
2616 case mfSCRIPT11:
2617 case mfSCRIPT12:
2618 case mfSCRIPT13:
2619 case mfSCRIPT14:
2620 case mfSCRIPT15:
2621 case mfSCRIPT16:
2622 case mfSCRIPT17:
2623 case mfSCRIPT18:
2624 case mfSCRIPT19:
2625 case mfSCRIPT20:
2626 case mfPITHOLE:
2627 case mfPITFALLFLOOR:
2628 case mfLAVA:
2629 case mfICE:
2630 case mfICEDAMAGE:
2631 case mfDAMAGE1:
2632 case mfDAMAGE2:
2633 case mfDAMAGE4:
2634 case mfDAMAGE8:
2635 case mfDAMAGE16:
2636 case mfDAMAGE32:
2637 case mfFREEZEALL:
2638 case mfFREZEALLANSFFCS:
2639 case mfFREEZEFFCSOLY:
2640 case mfSCRITPTW1TRIG:
2641 case mfSCRITPTW2TRIG:
2642 case mfSCRITPTW3TRIG:
2643 case mfSCRITPTW4TRIG:
2644 case mfSCRITPTW5TRIG:
2645 case mfSCRITPTW6TRIG:
2646 case mfSCRITPTW7TRIG:
2647 case mfSCRITPTW8TRIG:
2648 case mfSCRITPTW9TRIG:
2649 case mfSCRITPTW10TRIG:
2650 case mfTROWEL:
2651 case mfTROWELNEXT:
2652 case mfTROWELSPECIALITEM:
2653 case mfSLASHPOT:
2654 case mfLIFTPOT:
2655 case mfLIFTORSLASH:
2656 case mfLIFTROCK:
2657 case mfLIFTROCKHEAVY:
2658 case mfDROPITEM:
2659 case mfSPECIALITEM:
2660 case mfDROPKEY:
2661 case mfDROPLKEY:
2662 case mfDROPCOMPASS:
2663 case mfDROPMAP:
2664 case mfDROPBOSSKEY:
2665 case mfSPAWNNPC:
2666 case mfSWITCHHOOK:
2667 case mfSIDEVIEWLADDER:
2668 case mfSIDEVIEWPLATFORM:
2669 case mfNOENEMYSPAWN:
2670 case mfENEMYALL:
2671 case mfNOMIRROR:
2672 case mfUNSAFEGROUND:
2673 case mf168:
2674 case mf169:
2675 case mf170:
2676 case mf171:
2677 case mf172:
2678 case mf173:
2679 case mf174:
2680 case mf175:
2681 case mf176:
2682 case mf177:
2683 case mf178:
2684 case mf179:
2685 case mf180:
2686 case mf181:
2687 case mf182:
2688 case mf183:
2689 case mf184:
2690 case mf185:
2691 case mf186:
2692 case mf187:
2693 case mf188:
2694 case mf189:
2695 case mf190:
2696 case mf191:
2697 case mf192:
2698 case mf193:
2699 case mf194:
2700 case mf195:
2701 case mf196:
2702 case mf197:
2703 case mf198:
2704 case mf199:
2705 case mf200:
2706 case mf201:
2707 case mf202:
2708 case mf203:
2709 case mf204:
2710 case mf205:
2711 case mf206:
2712 case mf207:
2713 case mf208:
2714 case mf209:
2715 case mf210:
2716 case mf211:
2717 case mf212:
2718 case mf213:
2719 case mf214:
2720 case mf215:
2721 case mf216:
2722 case mf217:
2723 case mf218:
2724 case mf219:
2725 case mf220:
2726 case mf221:
2727 case mf222:
2728 case mf223:
2729 case mf224:
2730 case mf225:
2731 case mf226:
2732 case mf227:
2733 case mf228:
2734 case mf229:
2735 case mf230:
2736 case mf231:
2737 case mf232:
2738 case mf233:
2739 case mf234:
2740 case mf235:
2741 case mf236:
2742 case mf237:
2743 case mf238:
2744 case mf239:
2745 case mf240:
2746 case mf241:
2747 case mf242:
2748 case mf243:
2749 case mf244:
2750 case mf245:
2751 case mf246:
2752 case mf247:
2753 case mf248:
2754 case mf249:
2755 case mf250:
2756 case mf251:
2757 case mf252:
2758 case mf253:
2759 case mf254:
2760 case mfEXTENDED:
2761 5706470 break;
2762
2763 case mfPUSHUD:
2764 case mfPUSHLR:
2765 case mfPUSH4:
2766 case mfPUSHU:
2767 case mfPUSHD:
2768 case mfPUSHL:
2769 case mfPUSHR:
2770 case mfPUSHUDNS:
2771 case mfPUSHLRNS:
2772 case mfPUSH4NS:
2773 case mfPUSHUNS:
2774 case mfPUSHDNS:
2775 case mfPUSHLNS:
2776 case mfPUSHRNS:
2777 case mfPUSHUDINS:
2778 case mfPUSHLRINS:
2779 case mfPUSH4INS:
2780 case mfPUSHUINS:
2781 case mfPUSHDINS:
2782 case mfPUSHLINS:
2783 case mfPUSHRINS:
2784
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2785
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2786 {
2787 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2788 }
2789
2790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2791
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2792 {
2793
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2794 {
2795
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2796 {
2797 case cPUSH_HEAVY:
2798 case cPUSH_HW:
2799 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2800 72 tempitemx=x, tempitemy=y;
2801
2802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2803 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2804
2805 72 break;
2806
2807 case cPUSH_HEAVY2:
2808 case cPUSH_HW2:
2809 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2810 63 tempitemx=x, tempitemy=y;
2811
2812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2813 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2814
2815 63 break;
2816 }
2817 1032 }
2818 2438 }
2819
2820 3148 break;
2821
2822 case mfWHISTLE:
2823
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2824 {
2825 tempitem=getItemID(itemsbuf,itype_whistle,1);
2826
2827 if(tempitem<0) break;
2828
2829 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2830 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2831 {
2832 tempitemx=x;
2833 tempitemy=y;
2834 }
2835
2836 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2837 }
2838
2839 2418 break;
2840
2841 //Why is this here?
2842 case mfFAIRY:
2843 case mfMAGICFAIRY:
2844 case mfALLFAIRY:
2845 if(hints)
2846 {
2847 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2848
2849 if(tempitem < 0) break;
2850
2851 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2852 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2853 {
2854 tempitemx=x;
2855 tempitemy=y;
2856 }
2857
2858 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2859 }
2860
2861 break;
2862
2863 case mfANYFIRE:
2864
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2865 {
2866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2867 252 }
2868 else
2869 {
2870 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2871
2872
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2873
2874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2875
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2876 {
2877 189 tempitemx=x;
2878 189 tempitemy=y;
2879 189 }
2880
2881 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2882 }
2883
2884 504 break;
2885
2886 case mfSTRONGFIRE:
2887 if(!hints)
2888 {
2889 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2890 }
2891 else
2892 {
2893 tempitem=getItemID(itemsbuf,itype_candle,2);
2894
2895 if(tempitem<0) break;
2896
2897 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2898 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2899 {
2900 tempitemx=x;
2901 tempitemy=y;
2902 }
2903
2904 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2905 }
2906
2907 break;
2908
2909 case mfMAGICFIRE:
2910 if(!hints)
2911 {
2912 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2913 }
2914 else
2915 {
2916 tempitem=getItemID(itemsbuf,itype_wand,1);
2917
2918 if(tempitem<0) break;
2919
2920 tempweapon=wFire;
2921
2922 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2923 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2924 {
2925 tempitemx=x;
2926 tempitemy=y;
2927 }
2928 else
2929 {
2930 tempweaponx=x;
2931 tempweapony=y;
2932 }
2933
2934 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2935 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2936 }
2937
2938 break;
2939
2940 case mfDIVINEFIRE:
2941 if(!hints)
2942 {
2943 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2944 }
2945 else
2946 {
2947 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2948
2949 if(tempitem<0) break;
2950
2951 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2952 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2953 {
2954 tempitemx=x;
2955 tempitemy=y;
2956 }
2957
2958 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2959 }
2960
2961 break;
2962
2963 case mfARROW:
2964
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2965 {
2966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2967 732 }
2968 else
2969 {
2970 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2971
2972
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2973
2974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2975
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2976 {
2977 61 tempitemx=x;
2978 61 tempitemy=y;
2979 61 }
2980
2981 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2982 }
2983
2984 814 break;
2985
2986 case mfSARROW:
2987 if(!hints)
2988 {
2989 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2990 }
2991 else
2992 {
2993 tempitem=getItemID(itemsbuf,itype_arrow,2);
2994
2995 if(tempitem<0) break;
2996
2997 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2998 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2999 {
3000 tempitemx=x;
3001 tempitemy=y;
3002 }
3003
3004 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3005 }
3006
3007 break;
3008
3009 case mfGARROW:
3010 if(!hints)
3011 {
3012 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3013 }
3014 else
3015 {
3016 tempitem=getItemID(itemsbuf,itype_arrow,3);
3017
3018 if(tempitem<0) break;
3019
3020 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3021 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3022 {
3023 tempitemx=x;
3024 tempitemy=y;
3025 }
3026
3027 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3028 }
3029
3030 break;
3031
3032 case mfBOMB:
3033
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3034 {
3035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3036 16 }
3037 else
3038 {
3039 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3040 17 tempweapon = wLitBomb;
3041
3042 //if (tempitem<0) break;
3043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3044
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3045 {
3046 12 tempweaponx=x;
3047 12 tempweapony=y;
3048 12 }
3049
3050 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3051 }
3052
3053 33 break;
3054
3055 case mfSBOMB:
3056
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3057 {
3058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3059 48 }
3060 else
3061 {
3062 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3063 //if (tempitem<0) break;
3064 48 tempweapon = wLitSBomb;
3065
3066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3067
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3068 {
3069 36 tempweaponx=x;
3070 36 tempweapony=y;
3071 36 }
3072
3073 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3074 }
3075
3076 96 break;
3077
3078 case mfARMOS_SECRET:
3079
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3080 {
3081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3082 12 }
3083 24 break;
3084
3085 case mfBRANG:
3086
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3087 {
3088 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3089 }
3090 else
3091 {
3092 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3093
3094
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3095
3096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3097
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3098 {
3099 4 tempitemx=x;
3100 4 tempitemy=y;
3101 4 }
3102
3103 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3104 }
3105
3106 5 break;
3107
3108 case mfMBRANG:
3109 if(!hints)
3110 {
3111 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3112 }
3113 else
3114 {
3115 tempitem=getItemID(itemsbuf,itype_brang,2);
3116
3117 if(tempitem<0) break;
3118
3119 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3120 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3121 {
3122 tempitemx=x;
3123 tempitemy=y;
3124 }
3125
3126 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3127 }
3128
3129 break;
3130
3131 case mfFBRANG:
3132 if(!hints)
3133 {
3134 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3135 }
3136 else
3137 {
3138 tempitem=getItemID(itemsbuf,itype_brang,3);
3139
3140 if(tempitem<0) break;
3141
3142 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3143 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3144 {
3145 tempitemx=x;
3146 tempitemy=y;
3147 }
3148
3149 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3150 }
3151
3152 break;
3153
3154 case mfWANDMAGIC:
3155 if(!hints)
3156 {
3157 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3158 }
3159 else
3160 {
3161 tempitem=getItemID(itemsbuf,itype_wand,1);
3162
3163 if(tempitem<0) break;
3164
3165 tempweapon=itemsbuf[tempitem].wpn3;
3166
3167 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3168 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3169 {
3170 tempitemx=x;
3171 tempitemy=y;
3172 }
3173 else
3174 {
3175 tempweaponx=x;
3176 tempweapony=y;
3177 --lens_hint_weapon[wMagic][4];
3178
3179 if(lens_hint_weapon[wMagic][4]<-8)
3180 {
3181 lens_hint_weapon[wMagic][4]=8;
3182 }
3183 }
3184
3185 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3186 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3187 }
3188
3189 break;
3190
3191 case mfREFMAGIC:
3192
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3193 {
3194 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3195 }
3196 else
3197 {
3198 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3199
3200
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3201
3202 16 tempweapon=ewMagic;
3203
3204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3205
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3206 {
3207 13 tempitemx=x;
3208 13 tempitemy=y;
3209 13 }
3210 else
3211 {
3212 3 tempweaponx=x;
3213 3 tempweapony=y;
3214
3215
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3216 {
3217 1 --lens_hint_weapon[ewMagic][4];
3218 1 }
3219 else
3220 {
3221 2 ++lens_hint_weapon[ewMagic][4];
3222 }
3223
3224
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3225 {
3226 lens_hint_weapon[ewMagic][2]=up;
3227 }
3228
3229
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3230 {
3231 2 lens_hint_weapon[ewMagic][2]=down;
3232 2 }
3233 }
3234
3235 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3236 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3237 }
3238
3239 16 break;
3240
3241 case mfREFFIREBALL:
3242
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3243 {
3244 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3245 }
3246 else
3247 {
3248 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3249
3250
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3251
3252 16 tempweapon=ewFireball;
3253
3254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3255
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3256 {
3257 12 tempitemx=x;
3258 12 tempitemy=y;
3259 12 tempweaponx=x;
3260 12 tempweapony=y;
3261 12 ++lens_hint_weapon[ewFireball][3];
3262
3263
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3264 {
3265 1 lens_hint_weapon[ewFireball][3]=-8;
3266 1 lens_hint_weapon[ewFireball][4]=8;
3267 1 }
3268
3269
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3270 {
3271 8 ++lens_hint_weapon[ewFireball][4];
3272 8 }
3273 else
3274 {
3275 4 --lens_hint_weapon[ewFireball][4];
3276 }
3277 12 }
3278
3279 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3280 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3281 }
3282
3283 16 break;
3284
3285 case mfSWORD:
3286
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3287 {
3288 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3289 }
3290 else
3291 {
3292 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3293
3294
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3295
3296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3297
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3298 {
3299 5 tempitemx=x;
3300 5 tempitemy=y;
3301 5 }
3302
3303 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3304 }
3305
3306 7 break;
3307
3308 case mfWSWORD:
3309 if(!hints)
3310 {
3311 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3312 }
3313 else
3314 {
3315 tempitem=getItemID(itemsbuf,itype_sword,2);
3316
3317 if(tempitem<0) break;
3318
3319 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3320 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3321 {
3322 tempitemx=x;
3323 tempitemy=y;
3324 }
3325
3326 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3327 }
3328
3329 break;
3330
3331 case mfMSWORD:
3332 if(!hints)
3333 {
3334 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3335 }
3336 else
3337 {
3338 tempitem=getItemID(itemsbuf,itype_sword,3);
3339
3340 if(tempitem<0) break;
3341
3342 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3343 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3344 {
3345 tempitemx=x;
3346 tempitemy=y;
3347 }
3348
3349 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3350 }
3351
3352 break;
3353
3354 case mfXSWORD:
3355 if(!hints)
3356 {
3357 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3358 }
3359 else
3360 {
3361 tempitem=getItemID(itemsbuf,itype_sword,4);
3362
3363 if(tempitem<0) break;
3364
3365 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3366 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3367 {
3368 tempitemx=x;
3369 tempitemy=y;
3370 }
3371
3372 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3373 }
3374
3375 break;
3376
3377 case mfSWORDBEAM:
3378
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3379 {
3380 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3381 }
3382 else
3383 {
3384 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3385
3386
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3387
3388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3389
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3390 {
3391 11 tempitemx=x;
3392 11 tempitemy=y;
3393 11 }
3394
3395 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3396 }
3397
3398 16 break;
3399
3400 case mfWSWORDBEAM:
3401 if(!hints)
3402 {
3403 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3404 }
3405 else
3406 {
3407 tempitem=getItemID(itemsbuf,itype_sword,2);
3408
3409 if(tempitem<0) break;
3410
3411 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3412 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3413 {
3414 tempitemx=x;
3415 tempitemy=y;
3416 }
3417
3418 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3419 }
3420
3421 break;
3422
3423 case mfMSWORDBEAM:
3424 if(!hints)
3425 {
3426 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3427 }
3428 else
3429 {
3430 tempitem=getItemID(itemsbuf,itype_sword,3);
3431
3432 if(tempitem<0) break;
3433
3434 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3435 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3436 {
3437 tempitemx=x;
3438 tempitemy=y;
3439 }
3440
3441 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3442 }
3443
3444 break;
3445
3446 case mfXSWORDBEAM:
3447 if(!hints)
3448 {
3449 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3450 }
3451 else
3452 {
3453 tempitem=getItemID(itemsbuf,itype_sword,4);
3454
3455 if(tempitem<0) break;
3456
3457 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3458 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3459 {
3460 tempitemx=x;
3461 tempitemy=y;
3462 }
3463
3464 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3465 }
3466
3467 break;
3468
3469 case mfHOOKSHOT:
3470
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3471 {
3472 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3473 }
3474 else
3475 {
3476 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3477
3478
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3479
3480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3481
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3482 {
3483 12 tempitemx=x;
3484 12 tempitemy=y;
3485 12 }
3486
3487 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3488 }
3489
3490 17 break;
3491
3492 case mfWAND:
3493
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3494 {
3495 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3496 }
3497 else
3498 {
3499 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3500
3501
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3502
3503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3504
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3505 {
3506 28 tempitemx=x;
3507 28 tempitemy=y;
3508 28 }
3509
3510 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3511 }
3512
3513 35 break;
3514
3515 case mfHAMMER:
3516
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3517 {
3518 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3519 }
3520 else
3521 {
3522 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3523
3524
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3525
3526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3527
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3528 {
3529 13 tempitemx=x;
3530 13 tempitemy=y;
3531 13 }
3532
3533 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3534 }
3535
3536 17 break;
3537
3538 case mfARMOS_ITEM:
3539 case mfDIVE_ITEM:
3540
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3541 {
3542 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3543 2064 }
3544 2064 break;
3545
3546 case 16:
3547 case 17:
3548 case 18:
3549 case 19:
3550 case 20:
3551 case 21:
3552 case 22:
3553 case 23:
3554 case 24:
3555 case 25:
3556 case 26:
3557 case 27:
3558 case 28:
3559 case 29:
3560 case 30:
3561 case 31:
3562
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3564 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3565
3566 3618 break;
3567 case mfSECRETSNEXT:
3568 if(!hints)
3569 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3570 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3571
3572 break;
3573
3574 case mfSTRIKE:
3575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3576 {
3577 906 goto special;
3578 }
3579 else
3580 {
3581 break;
3582 }
3583
3584 28640 default: goto special;
3585
3586 special:
3587
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3588 {
3589
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3590 {
3591 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3592 4913 }
3593 6549 }
3594
3595 29546 break;
3596 }
3597 5748864 }
3598 2874432 }
3599
3600
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3601 {
3602
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3603 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3604
3605
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3606 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3607
3608
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3609 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3610
3611
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3612 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3613
3614
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3615 {
3616 43 showbombeddoor(dest, 0);
3617 43 }
3618
3619
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3620 {
3621 39 showbombeddoor(dest, 1);
3622 39 }
3623
3624
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3625 {
3626 showbombeddoor(dest, 2);
3627 }
3628
3629
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3630 {
3631 37 showbombeddoor(dest, 3);
3632 37 }
3633 8166 }
3634
3635
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3636 {
3637
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3638 {
3639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3640 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3641 1123 }
3642 else
3643 {
3644
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3645 {
3646 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3647 48 int32_t tempitemx=-16;
3648 48 int32_t tempitemy=-16;
3649
3650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3651
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3652 {
3653 24 tempitemx=tmpscr->stairx;
3654 24 tempitemy=tmpscr->stairy+playing_field_offset;
3655 24 }
3656
3657 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3658 48 }
3659 }
3660 2034 }
3661 }
3662 16332 }
3663
3664 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3665
3666 7997 void draw_lens_over()
3667 {
3668 // Oh, what the heck.
3669 static BITMAP *lens_scr = NULL;
3670 static int32_t last_width = -1;
3671 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3672
3673 // Only redraw the circle if the size has changed
3674
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3675 {
3676
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3677 {
3678 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3679 5 }
3680
3681 5 clear_to_color(lens_scr, BLACK);
3682 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3683 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3684 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3685 5 last_width=width;
3686 5 }
3687
3688 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3689 7997 }
3690
3691 //----------------------------------------------------------------
3692
3693 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3694 {
3695 //recreating a big bitmap every frame is highly sluggish.
3696
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3697 30701 clear_to_color(wavebuf, BLACK);
3698 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3699
3700 int32_t ofs;
3701 // int32_t amplitude=8;
3702 // int32_t wavelength=4;
3703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3704
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3705 30701 int32_t amp2=168;
3706
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3707 30701 int32_t i=frame%amp2;
3708
3709
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3710 {
3711
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3712 {
3713 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3714 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3715 }
3716 else
3717 {
3718 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3719 }
3720
3721
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3722 {
3723
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3724 {
3725 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3726 1320388608 }
3727 5157768 }
3728 5157768 }
3729 30701 }
3730
3731 3360 void draw_fuzzy(int32_t fuzz)
3732 // draws from right half of scrollbuf to framebuf
3733 {
3734 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3735 byte *start, *si, *di;
3736
3737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 if(fuzz<1)
3738 fuzz = 1;
3739
3740 3360 xstep = 128%fuzz;
3741
3742
2/2
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 2660 times.
3360 if(xstep > 0)
3743 2660 xstep = fuzz-xstep;
3744
3745 3360 ystep = 112%fuzz;
3746
3747
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 2380 times.
3360 if(ystep > 0)
3748 2380 ystep = fuzz-ystep;
3749
3750 3360 firsty = 1;
3751
3752
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 121240 times.
124600 for(y=0; y<224;)
3753 {
3754 121240 start = &(scrollbuf->line[y][256]);
3755
3756
4/4
✓ Branch 0 taken 119560 times.
✓ Branch 1 taken 754320 times.
✓ Branch 2 taken 752640 times.
✓ Branch 3 taken 121240 times.
873880 for(dy=0; dy<ystep && dy+y<224; dy++)
3757 {
3758 752640 si = start;
3759 752640 di = &(framebuf->line[y+dy][0]);
3760 752640 i = xstep;
3761 752640 firstx = 1;
3762
3763
2/2
✓ Branch 0 taken 192675840 times.
✓ Branch 1 taken 752640 times.
193428480 for(dx=0; dx<256; dx++)
3764 {
3765 192675840 *(di++) = *si;
3766
3767
2/2
✓ Branch 0 taken 162350720 times.
✓ Branch 1 taken 30325120 times.
192675840 if(++i >= fuzz)
3768 {
3769
2/2
✓ Branch 0 taken 29572480 times.
✓ Branch 1 taken 752640 times.
30325120 if(!firstx)
3770 29572480 si += fuzz;
3771 else
3772 {
3773 752640 si += fuzz-xstep;
3774 752640 firstx = 0;
3775 }
3776
3777 30325120 i = 0;
3778 30325120 }
3779 192675840 }
3780 752640 }
3781
3782
2/2
✓ Branch 0 taken 117880 times.
✓ Branch 1 taken 3360 times.
121240 if(!firsty)
3783 117880 y += fuzz;
3784 else
3785 {
3786 3360 y += ystep;
3787 3360 ystep = fuzz;
3788 3360 firsty = 0;
3789 }
3790 }
3791 3360 }
3792
3793 8114131 void updatescr(bool allowwavy)
3794 {
3795
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 8114095 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
8114131 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3796
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 8114095 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
8114131 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3797
3798
2/2
✓ Branch 0 taken 8088427 times.
✓ Branch 1 taken 25704 times.
8114131 if(toogam)
3799 {
3800 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3801 25704 }
3802
3803
1/2
✓ Branch 0 taken 8114131 times.
✗ Branch 1 not taken.
8114131 if(Showpal)
3804 dump_pal(framebuf);
3805
3806
2/2
✓ Branch 0 taken 7940999 times.
✓ Branch 1 taken 173132 times.
8114131 if(!Playing)
3807 173132 black_opening_count=0;
3808
3809
2/2
✓ Branch 0 taken 8059879 times.
✓ Branch 1 taken 54252 times.
8114131 if(black_opening_count<0) //shape is opening up
3810 {
3811 54252 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3812
3813
2/4
✓ Branch 0 taken 54252 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54252 times.
54252 if(Advance||(!Paused))
3814 {
3815 54252 ++black_opening_count;
3816 54252 }
3817 54252 }
3818
2/2
✓ Branch 0 taken 8039353 times.
✓ Branch 1 taken 20526 times.
8059879 else if(black_opening_count>0) //shape is closing
3819 {
3820 20526 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3821
3822
2/4
✓ Branch 0 taken 20526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20526 times.
20526 if(Advance||(!Paused))
3823 {
3824 20526 --black_opening_count;
3825 20526 }
3826 20526 }
3827
3828
3/4
✓ Branch 0 taken 8040486 times.
✓ Branch 1 taken 73645 times.
✓ Branch 2 taken 8040486 times.
✗ Branch 3 not taken.
8114131 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3829 {
3830 black_opening_shape = bosCIRCLE;
3831 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3832 refreshTints();
3833 refreshpal=true;
3834 }
3835
3836
2/2
✓ Branch 0 taken 7869222 times.
✓ Branch 1 taken 244909 times.
8114131 if(refreshpal)
3837 {
3838 244909 refreshpal=false;
3839 244909 RAMpal[253] = _RGB(0,0,0);
3840 244909 RAMpal[254] = _RGB(63,63,63);
3841 244909 hw_palette = &RAMpal;
3842 244909 update_hw_pal = true;
3843
3844 244909 create_rgb_table(&rgb_table, RAMpal, NULL);
3845 244909 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3846 244909 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3847
3848
2/2
✓ Branch 0 taken 62696704 times.
✓ Branch 1 taken 244909 times.
62941613 for(int32_t q=0; q<PAL_SIZE; q++)
3849 {
3850 62696704 trans_table2.data[0][q] = q;
3851 62696704 trans_table2.data[q][q] = q;
3852 62696704 }
3853 244909 }
3854
3855 8114131 bool clearwavy = (wavy <= 0);
3856
3857
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 8106886 times.
8114131 if(wavy <= 0)
3858 {
3859 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3860 8106886 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3861 8106886 }
3862
3863 8114131 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3864
3865
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 8083180 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
8114131 if(wavy && Playing && allowwavy)
3866 {
3867 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3868 30701 }
3869
3870
2/2
✓ Branch 0 taken 8106886 times.
✓ Branch 1 taken 7245 times.
8114131 if(clearwavy)
3871 8106886 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3872
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3873 7245 wavy--; // Wavy was set by a script. Decrement it.
3874
3875
5/6
✓ Branch 0 taken 7940999 times.
✓ Branch 1 taken 173132 times.
✓ Branch 2 taken 184496 times.
✓ Branch 3 taken 7756503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 184496 times.
8114131 if(Playing && msgpos && !screenscrolling)
3876 {
3877
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_bg_display_buf->clip))
3878 184496 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3879
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_portrait_display_buf->clip))
3880 184496 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3881
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_txt_display_buf->clip))
3882 184496 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3883 184496 }
3884
3885 /*
3886 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3887 {
3888 BITMAP* subBmp = 0;
3889 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3890 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3891 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3892 destroy_bitmap(subBmp);
3893 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3894 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3895 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3896 }
3897 */
3898
3899
2/2
✓ Branch 0 taken 8076614 times.
✓ Branch 1 taken 37517 times.
8114131 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3900
3901
2/2
✓ Branch 0 taken 8081239 times.
✓ Branch 1 taken 32892 times.
8114131 if(nosubscr)
3902 {
3903 32892 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3904 32892 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3905 32892 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3906 32892 }
3907
3908 //TODO: Optimize blit 'overcalls' -Gleeok
3909
2/2
✓ Branch 0 taken 32892 times.
✓ Branch 1 taken 8081239 times.
8114131 BITMAP *source = nosubscr ? panorama : wavybuf;
3910 8114131 blit(source,framebuf,0,0,0,0,256,224);
3911
3912 8114131 update_hw_screen();
3913 8114131 }
3914
3915 //----------------------------------------------------------------
3916
3917 static PALETTE syspal;
3918 int32_t onGUISnapshot()
3919 {
3920 char buf[200];
3921 int32_t num=0;
3922 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3923 do
3924 {
3925 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3926 }
3927 while(num<99999 && exists(buf));
3928
3929 BITMAP *b = create_bitmap_ex(8,resx,resy);
3930
3931 if(b)
3932 {
3933 blit(screen,b,0,0,0,0,resx,resy);
3934 save_bitmap(buf,b,RAMpal);
3935 destroy_bitmap(b);
3936 }
3937
3938 return D_O_K;
3939 }
3940
3941 int32_t onNonGUISnapshot()
3942 {
3943 PALETTE temppal;
3944 get_palette(temppal);
3945 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3946
3947 char buf[200];
3948 int32_t num=0;
3949
3950 do
3951 {
3952 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3953 }
3954 while(num<99999 && exists(buf));
3955
3956 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3957
3958 return D_O_K;
3959 }
3960
3961 int32_t onSnapshot()
3962 {
3963 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3964 {
3965 onGUISnapshot();
3966 }
3967 else
3968 {
3969 onNonGUISnapshot();
3970 }
3971
3972 return D_O_K;
3973 }
3974
3975 int32_t onSaveMapPic()
3976 {
3977 int32_t mapres2 = 0;
3978 char buf[200];
3979 int32_t num=0;
3980 mapscr tmpscr_b[2];
3981 mapscr tmpscr_c[6];
3982 BITMAP* _screen_draw_buffer = NULL;
3983 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3984 set_clip_state(_screen_draw_buffer,1);
3985
3986 for(int32_t i=0; i<6; ++i)
3987 {
3988 tmpscr_c[i] = tmpscr2[i];
3989 tmpscr2[i].zero_memory();
3990
3991 if(i>=2)
3992 {
3993 continue;
3994 }
3995
3996 tmpscr_b[i] = tmpscr[i];
3997 tmpscr[i].zero_memory();
3998 }
3999
4000 do
4001 {
4002 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4003 }
4004 while(num<99999 && exists(buf));
4005
4006 BITMAP* mappic = NULL;
4007
4008
4009 bool done=false, redraw=true;
4010
4011 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4012
4013 if(!mappic)
4014 {
4015 enter_sys_pal();
4016 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4017 exit_sys_pal();
4018 return D_O_K;;
4019 }
4020
4021 // draw the map
4022 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4023
4024 for(int32_t y=0; y<8; y++)
4025 {
4026 for(int32_t x=0; x<16; x++)
4027 {
4028 if(!displayOnMap(x, y))
4029 {
4030 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4031 }
4032 else
4033 {
4034 int32_t s = (y<<4) + x;
4035 loadscr2(1,s,-1);
4036
4037 for(int32_t i=0; i<6; i++)
4038 {
4039 if(tmpscr[1].layermap[i]<=0)
4040 continue;
4041
4042 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4043 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4044 {
4045 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4046
4047 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4048 }
4049 }
4050
4051 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4052
4053 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4054
4055 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4056 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4057
4058 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4059
4060 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4061 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4062 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4063 {
4064 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4065 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4066 }
4067 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4068
4069 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4070
4071 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4072 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4073 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4074 {
4075 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4076 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4077 }
4078 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4079 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4080
4081 }
4082
4083 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4084 }
4085 }
4086
4087 for(int32_t i=0; i<6; ++i)
4088 {
4089 tmpscr2[i]=tmpscr_c[i];
4090
4091 if(i>=2)
4092 {
4093 continue;
4094 }
4095
4096 tmpscr[i]=tmpscr_b[i];
4097 }
4098
4099 save_bitmap(buf,mappic,RAMpal);
4100 destroy_bitmap(mappic);
4101 destroy_bitmap(_screen_draw_buffer);
4102 return D_O_K;
4103 }
4104
4105 13 void f_Quit(int32_t type)
4106 {
4107
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(type==qQUIT && !Playing)
4108 return;
4109
4110 13 bool from_menu = is_sys_pal;
4111
4112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4113 {
4114 13 music_pause();
4115 13 pause_all_sfx();
4116 13 sys_mouse();
4117 13 }
4118 13 enter_sys_pal();
4119 13 clear_keybuf();
4120
4121
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (replay_is_active() && replay_get_version() <= 9)
4122 13 replay_poll();
4123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_is_replaying())
4124 13 replay_peek_quit();
4125
4126
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (!replay_is_replaying())
4127 switch(type)
4128 {
4129 case qQUIT:
4130 onQuit();
4131 break;
4132
4133 case qRESET:
4134 onReset();
4135 break;
4136
4137 case qEXIT:
4138 onExit();
4139 break;
4140 }
4141
4142
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Quit)
4143 {
4144 13 kill_sfx();
4145 13 music_stop();
4146 13 exit_sys_pal();
4147 13 update_hw_screen();
4148 13 }
4149 else
4150 {
4151 exit_sys_pal();
4152 if(!from_menu)
4153 {
4154 music_resume();
4155 resume_all_sfx();
4156 }
4157 }
4158
4159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4160 13 game_mouse();
4161 13 eat_buttons();
4162
4163 13 zc_readrawkey(KEY_ESC);
4164
4165 13 zc_readrawkey(KEY_ENTER);
4166 13 }
4167
4168 //----------------------------------------------------------------
4169
4170 int32_t onNoWalls()
4171 {
4172 cheats_enqueue(Cheat::Walls);
4173 return D_O_K;
4174 }
4175
4176 int32_t onIgnoreSideview()
4177 {
4178 cheats_enqueue(Cheat::IgnoreSideView);
4179 return D_O_K;
4180 }
4181
4182 8114047 int32_t input_idle(bool checkmouse)
4183 {
4184 static int32_t mx, my, mz, mb;
4185
4186
4/6
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2127187 times.
✓ Branch 3 taken 5986860 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2127187 times.
10241234 if(keypressed() || zc_key_pressed() ||
4187
4/8
✓ Branch 0 taken 2127187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2127187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2127187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2127187 times.
✗ Branch 7 not taken.
2127187 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4188 {
4189 5986860 idle_count = 0;
4190
4191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5986860 times.
5986860 if(active_count < MAX_ACTIVE)
4192 {
4193 5986860 ++active_count;
4194 5986860 }
4195 5986860 }
4196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2127187 times.
2127187 else if(idle_count < MAX_IDLE)
4197 {
4198 2127187 ++idle_count;
4199 2127187 active_count = 0;
4200 2127187 }
4201
4202 8114047 mx = mouse_x;
4203 8114047 my = mouse_y;
4204 8114047 mz = mouse_z;
4205 8114047 mb = mouse_b;
4206
4207 8114047 return idle_count;
4208 }
4209
4210 int32_t onGoFast()
4211 {
4212 cheats_enqueue(Cheat::Fast);
4213 return D_O_K;
4214 }
4215
4216 int32_t onKillCheat()
4217 {
4218 cheats_enqueue(Cheat::Kill);
4219 return D_O_K;
4220 }
4221
4222 int32_t onSecretsCheat()
4223 {
4224 cheats_enqueue(Cheat::TrigSecrets);
4225 return D_O_K;
4226 }
4227 int32_t onSecretsCheatPerm()
4228 {
4229 cheats_enqueue(Cheat::TrigSecretsPerm);
4230 return D_O_K;
4231 }
4232
4233 int32_t onShowLayer0()
4234 {
4235 show_layer_0 = !show_layer_0;
4236 return D_O_K;
4237 }
4238 int32_t onShowLayer1()
4239 {
4240 show_layer_1 = !show_layer_1;
4241 return D_O_K;
4242 }
4243 int32_t onShowLayer2()
4244 {
4245 show_layer_2 = !show_layer_2;
4246 return D_O_K;
4247 }
4248 int32_t onShowLayer3()
4249 {
4250 show_layer_3 = !show_layer_3;
4251 return D_O_K;
4252 }
4253 int32_t onShowLayer4()
4254 {
4255 show_layer_4 = !show_layer_4;
4256 return D_O_K;
4257 }
4258 int32_t onShowLayer5()
4259 {
4260 show_layer_5 = !show_layer_5;
4261 return D_O_K;
4262 }
4263 int32_t onShowLayer6()
4264 {
4265 show_layer_6 = !show_layer_6;
4266 return D_O_K;
4267 }
4268 int32_t onShowLayerO()
4269 {
4270 show_layer_over=!show_layer_over;
4271 return D_O_K;
4272 }
4273 int32_t onShowLayerP()
4274 {
4275 show_layer_push=!show_layer_push;
4276 return D_O_K;
4277 }
4278 int32_t onShowLayerS()
4279 {
4280 show_sprites=!show_sprites;
4281 return D_O_K;
4282 }
4283 int32_t onShowLayerF()
4284 {
4285 show_ffcs=!show_ffcs;
4286 return D_O_K;
4287 }
4288 int32_t onShowLayerW()
4289 {
4290 show_walkflags=!show_walkflags;
4291 if(show_walkflags)
4292 show_effectflags = false;
4293 return D_O_K;
4294 }
4295 int32_t onShowLayerE()
4296 {
4297 show_effectflags=!show_effectflags;
4298 if(show_effectflags)
4299 show_walkflags = false;
4300 return D_O_K;
4301 }
4302 int32_t onShowFFScripts()
4303 {
4304 show_ff_scripts=!show_ff_scripts;
4305 return D_O_K;
4306 }
4307 int32_t onShowHitboxes()
4308 {
4309 show_hitboxes=!show_hitboxes;
4310 return D_O_K;
4311 }
4312 int32_t onShowInfoOpacity()
4313 {
4314 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4315 zc_set_config("zc","debug_info_opacity",info_opacity);
4316 return D_O_K;
4317 }
4318
4319 int32_t onLightSwitch()
4320 {
4321 cheats_enqueue(Cheat::Light);
4322 return D_O_K;
4323 }
4324
4325 int32_t onGoTo();
4326 int32_t onGoToComplete();
4327
4328 8114047 void syskeys()
4329 {
4330 8114047 update_system_keys();
4331
4332 int32_t oldtitle_version;
4333
4334
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if(close_button_quit)
4335 {
4336 close_button_quit=false;
4337 f_Quit(qEXIT);
4338 }
4339
4340 8114047 poll_joystick();
4341
4342
2/10
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8114047 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8114047 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4343 {
4344 oldtitle_version=title_version;
4345 System();
4346 }
4347
4348 8114047 mouse_down=gui_mouse_b();
4349
4350
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if(zc_read_system_key(KEY_F1))
4351 {
4352 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4353 {
4354 halt=!halt;
4355 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4356 }
4357 else
4358 {
4359 Throttlefps=!Throttlefps;
4360 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4361 logic_counter=0;
4362 }
4363 }
4364
4365 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4366 /*
4367 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4368 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4369 */
4370
4371
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if(zc_read_system_key(KEY_F2))
4372 {
4373 ShowFPS=!ShowFPS;
4374 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4375 }
4376
4377
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8114047 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8114047 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4378
4379
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8114047 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8114047 if(zc_read_system_key(KEY_F4) && Playing)
4380 {
4381 Paused=true;
4382 Advance=true;
4383 }
4384
4385
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if(zc_read_system_key(KEY_F6)) onTryQuit();
4386
4387 #ifndef ALLEGRO_MACOSX
4388
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4389
4390
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4391 #else
4392 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4393
4394 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4395 #endif
4396
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8114047 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8114047 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4397
4398
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if (zc_read_system_key(KEY_F12))
4399 {
4400 onSnapshot();
4401 }
4402
4403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8114047 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8114047 if(debug_enabled && zc_read_system_key(KEY_TAB))
4404 set_debug(!get_debug());
4405
4406
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if(CheatModifierKeys())
4407 {
4408 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4409 {
4410 if(!bindable_cheat(c))
4411 continue;
4412 if(get_debug() || cheat >= cheat_lvl(c))
4413 {
4414 if(checkcheat(c))
4415 cheats_hit_bind(c);
4416 }
4417 }
4418 }
4419
4420
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if(volkeys)
4421 {
4422 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4423
4424 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4425
4426 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4427
4428 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4429 }
4430
4431
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8114047 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8114047 if(!get_debug() || !SystemKeys || replay_is_replaying())
4432 8114047 goto bottom;
4433
4434 if(zc_readkey(KEY_D))
4435 {
4436 details = !details;
4437 rectfill(screen,0,0,319,7,BLACK);
4438 rectfill(screen,0,8,31,239,BLACK);
4439 rectfill(screen,288,8,319,239,BLACK);
4440 rectfill(screen,32,232,287,239,BLACK);
4441 }
4442
4443 if(zc_readkey(KEY_P)) Paused=!Paused;
4444
4445 //if(zc_readkey(KEY_P)) centerHero();
4446 if(zc_readkey(KEY_A))
4447 {
4448 Paused=true;
4449 Advance=true;
4450 }
4451
4452 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4453 #ifndef ALLEGRO_MACOSX
4454 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4455
4456 if(zc_readkey(KEY_F7))
4457 {
4458 Matrix(ss_speed, ss_density, 0);
4459 game_pal();
4460 }
4461 #else
4462 // The reason these are different on Mac in the first place is that
4463 // the OS doesn't let us use F9 and F10...
4464 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4465
4466 if(zc_readkey(KEY_F9))
4467 {
4468 Matrix(ss_speed, ss_density, 0);
4469 game_pal();
4470 }
4471 #endif
4472 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4473 {
4474 //change containers
4475 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4476 {
4477 //magic containers
4478 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4479 {
4480 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4481 }
4482 else
4483 {
4484 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4485 }
4486 }
4487 else
4488 {
4489 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4490 {
4491 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4492 }
4493 else
4494 {
4495 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4496 }
4497 }
4498 }
4499
4500 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4501 {
4502 //change containers
4503 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4504 {
4505 //magic containers
4506 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4507 {
4508 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4509 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4510 //heart containers
4511 }
4512 else
4513 {
4514 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4515 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4516 }
4517 }
4518 else
4519 {
4520 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4521 {
4522 game->set_magic(zc_max(game->get_magic()-1,0));
4523 }
4524 else
4525 {
4526 game->set_life(zc_max(game->get_life()-1,0));
4527 }
4528 }
4529 }
4530
4531 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4532
4533 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4534
4535 verifyBothWeapons();
4536
4537 bottom:
4538
4539
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if(input_idle(true) > after_time())
4540 {
4541 Matrix(ss_speed, ss_density, 0);
4542 game_pal();
4543 }
4544 8114047 }
4545
4546 425191 void checkQuitKeys()
4547 {
4548 #ifndef ALLEGRO_MACOSX
4549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425191 times.
425191 if(key[KEY_F9]) f_Quit(qRESET);
4550
4551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425191 times.
425191 if(key[KEY_F10]) f_Quit(qEXIT);
4552 #else
4553 if(key[KEY_F7]) f_Quit(qRESET);
4554
4555 if(key[KEY_F8]) f_Quit(qEXIT);
4556 #endif
4557 425191 }
4558
4559 8114047 bool CheatModifierKeys()
4560 {
4561 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4562 // to trigger cheats.
4563
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if (replay_is_replaying())
4564 8114047 return false;
4565
4566 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4567 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4568 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4569 {
4570 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4571 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4572 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4573 {
4574 return true;
4575 }
4576 }
4577 return false;
4578 8114047 }
4579
4580 //99:05:54, for some reason?
4581 #define OLDMAXTIME 21405240
4582 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4583 #define MAXTIME 1944000000
4584
4585 8114131 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4586 {
4587
2/2
✓ Branch 0 taken 7820546 times.
✓ Branch 1 taken 293585 times.
8114131 if(zcmusic!=NULL)
4588 {
4589 293585 zcmusic_poll();
4590 293585 }
4591
4592 8114131 updatescr(allowwavy);
4593
4594 8114131 Advance=false;
4595
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8114131 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8114131 times.
8114131 while(Paused && !Advance && !Quit)
4596 {
4597 // have to call this, otherwise we'll get an infinite loop
4598 syskeys();
4599 if(allowF6Script)
4600 {
4601 FFCore.runF6Engine();
4602 }
4603 throttleFPS();
4604
4605 #ifdef _WIN32
4606
4607 if(use_dwm_flush)
4608 {
4609 do_DwmFlush();
4610 }
4611
4612 #endif
4613
4614 // to keep music playing
4615 if(zcmusic!=NULL)
4616 {
4617 zcmusic_poll();
4618 }
4619
4620 update_hw_screen();
4621 }
4622
4623
2/2
✓ Branch 0 taken 8114059 times.
✓ Branch 1 taken 72 times.
8114131 if(Quit)
4624 72 return;
4625
4626
3/4
✓ Branch 0 taken 7940990 times.
✓ Branch 1 taken 173069 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7940990 times.
8114059 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4627 7940990 game->change_time(1);
4628
4629
5/6
✓ Branch 0 taken 8114059 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1509912 times.
✓ Branch 3 taken 6604147 times.
✓ Branch 4 taken 3778 times.
✓ Branch 5 taken 1506134 times.
8114059 if (replay_is_active() && replay_get_version() >= 11 && replay_get_version() < 16)
4630
2/2
✓ Branch 0 taken 27110412 times.
✓ Branch 1 taken 1506134 times.
28616546 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4631 28616546 down_control_states[i] = raw_control_state[i];
4632
4633
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8114061 times.
8114059 if (replay_is_active())
4634 {
4635
2/2
✓ Branch 0 taken 1270465 times.
✓ Branch 1 taken 6843596 times.
8114061 if (replay_get_version() >= 3)
4636 6843596 replay_poll();
4637
4638
6/6
✓ Branch 0 taken 6604137 times.
✓ Branch 1 taken 1509910 times.
✓ Branch 2 taken 3183485 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 3082950 times.
8114061 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4639 1610445 replay_peek_input();
4640 8114047 }
4641
4642 8114059 load_control_called_this_frame = false;
4643
4644 8114059 poll_keyboard();
4645 8114059 update_keys();
4646
4647 8114059 ++frame;
4648
4649
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8114047 times.
8114059 if (replay_is_replaying())
4650 8114047 replay_do_cheats();
4651 8114059 syskeys();
4652
4653 // The mouse variables can change from the mouse thread at anytime during a frame,
4654 // so save the result at the start so that replaying is consistent.
4655 8114059 script_mouse_x = gui_mouse_x();
4656 8114059 script_mouse_y = gui_mouse_y();
4657 8114059 script_mouse_z = mouse_z;
4658 8114059 script_mouse_b = mouse_b;
4659
4660 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4661 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4662 // approach here means it doesn't matter which call adds the cheat.
4663 8114059 cheats_execute_queued();
4664
4665
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8114047 times.
8114059 if (replay_is_replaying())
4666 8114047 replay_peek_quit();
4667
2/2
✓ Branch 0 taken 8114046 times.
✓ Branch 1 taken 13 times.
8114059 if (GameFlags & GAMEFLAG_TRYQUIT)
4668 13 replay_step_quit(0);
4669
2/2
✓ Branch 0 taken 2932 times.
✓ Branch 1 taken 8111127 times.
8114059 if(allowF6Script)
4670 8111127 FFCore.runF6Engine();
4671
2/2
✓ Branch 0 taken 8113832 times.
✓ Branch 1 taken 227 times.
8114059 if (Quit)
4672 227 replay_step_quit(Quit);
4673 // Someday... maybe install a Turbo button here?
4674 8114059 throttleFPS();
4675
4676 #ifdef _WIN32
4677
4678 if(use_dwm_flush)
4679 {
4680 do_DwmFlush();
4681 }
4682
4683 #endif
4684
4685 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4686
2/2
✓ Branch 0 taken 46694 times.
✓ Branch 1 taken 8067365 times.
8114059 if(sfxcleanup)
4687 8067365 sfx_cleanup();
4688 8114131 }
4689
4690 70 void zapout()
4691 {
4692 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4693 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4694
4695 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4696 70 script_drawing_commands.Clear();
4697
4698 // zap out
4699
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=1; i<=24; i++)
4700 {
4701 1680 draw_fuzzy(i);
4702 1680 advanceframe(true);
4703
4704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4705 {
4706 break;
4707 }
4708 1680 }
4709 70 }
4710
4711 70 void zapin()
4712 {
4713 70 FFCore.warpScriptCheck();
4714 70 draw_screen(tmpscr);
4715 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4716 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4717 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4718
4719 // zap out
4720 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4721
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=24; i>=1; i--)
4722 {
4723 1680 draw_fuzzy(i);
4724 1680 advanceframe(true);
4725
4726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4727 {
4728 break;
4729 }
4730 1680 }
4731 70 }
4732
4733
4734 38 void wavyout(bool showhero)
4735 {
4736 38 draw_screen(tmpscr, showhero);
4737 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4738
4739 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4740 38 clear_to_color(wavebuf,0);
4741 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4742
4743 static PALETTE wavepal;
4744
4745 int32_t ofs;
4746 38 int32_t amplitude=8;
4747
4748 38 int32_t wavelength=4;
4749 38 double palpos=0, palstep=4, palstop=126;
4750
4751 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4752
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4753 {
4754
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4755 {
4756 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4757 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4758 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4759 408576 }
4760
4761 1596 palpos+=palstep;
4762
4763
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
4764 {
4765 1596 hw_palette = &wavepal;
4766 1596 update_hw_pal = true;
4767 1596 }
4768 else
4769 {
4770 hw_palette = &RAMpal;
4771 update_hw_pal = true;
4772 }
4773
4774
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
4775 {
4776
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
4777 {
4778 68640768 ofs=0;
4779
4780
4/4
✓ Branch 0 taken 33503232 times.
✓ Branch 1 taken 35137536 times.
✓ Branch 2 taken 16751616 times.
✓ Branch 3 taken 16751616 times.
68640768 if((j<i)&&(j&1))
4781 {
4782 16751616 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4783 16751616 }
4784
4785 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4786 68640768 }
4787 268128 }
4788
4789 1596 advanceframe(true);
4790
4791 // animate_combos();
4792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
4793 break;
4794 1596 }
4795
4796 38 destroy_bitmap(wavebuf);
4797 38 }
4798
4799 38 void wavyin()
4800 {
4801 38 draw_screen(tmpscr);
4802 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4803
4804 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4805 38 clear_to_color(wavebuf,0);
4806 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4807
4808 static PALETTE wavepal;
4809
4810 //Breaks dark rooms.
4811 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4812 /*
4813 loadfullpal();
4814 loadlvlpal(DMaps[currdmap].color);
4815 ringcolor(false);
4816 */
4817 38 refreshpal=false;
4818 int32_t ofs;
4819 38 int32_t amplitude=8;
4820 38 int32_t wavelength=4;
4821 38 double palpos=168, palstep=4, palstop=126;
4822
4823 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4824
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4825 {
4826
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4827 {
4828 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4829 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4830 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4831 408576 }
4832
4833 1596 palpos-=palstep;
4834
4835
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
4836 {
4837 1596 hw_palette = &wavepal;
4838 1596 update_hw_pal = true;
4839 1596 }
4840 else
4841 {
4842 hw_palette = &RAMpal;
4843 update_hw_pal = true;
4844 }
4845
4846
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
4847 {
4848
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
4849 {
4850 68640768 ofs=0;
4851
4852
4/4
✓ Branch 0 taken 34728960 times.
✓ Branch 1 taken 33911808 times.
✓ Branch 2 taken 17568768 times.
✓ Branch 3 taken 17160192 times.
68640768 if((j<(167-i))&&(j&1))
4853 {
4854 17160192 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4855 17160192 }
4856
4857 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4858 68640768 }
4859 268128 }
4860
4861 1596 advanceframe(true);
4862 // animate_combos();
4863
4864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
4865 break;
4866 1596 }
4867
4868 38 destroy_bitmap(wavebuf);
4869 38 }
4870
4871 1921 void blackscr(int32_t fcnt,bool showsubscr)
4872 {
4873 1921 reset_pal_cycling();
4874 1921 script_drawing_commands.Clear();
4875
4876 1921 FFCore.warpScriptCheck();
4877 1921 bool showtime = game->should_show_time();
4878
2/2
✓ Branch 0 taken 1921 times.
✓ Branch 1 taken 57560 times.
59481 while(fcnt>0)
4879 {
4880 57560 clear_bitmap(framebuf);
4881
4882
2/2
✓ Branch 0 taken 19710 times.
✓ Branch 1 taken 37850 times.
57560 if(showsubscr)
4883 {
4884 37850 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
4885
3/4
✓ Branch 0 taken 37850 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 37100 times.
37850 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4886 {
4887 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4888 750 }
4889 37850 }
4890
4891 57560 advanceframe(true);
4892
4893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57560 times.
57560 if(Quit)
4894 break;
4895
4896 57560 --fcnt;
4897 }
4898 1921 }
4899
4900 726 void openscreen(int32_t shape)
4901 {
4902 726 reset_pal_cycling();
4903 726 black_opening_count=0;
4904
4905
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 627 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
726 if(COOLSCROLL || shape>-1)
4906 {
4907 627 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4908 627 return;
4909 }
4910 else
4911 {
4912 99 Hero.setDontDraw(true);
4913 99 show_subscreen_dmap_dots=false;
4914 99 show_subscreen_numbers=false;
4915 // show_subscreen_items=false;
4916 99 show_subscreen_life=false;
4917 }
4918
4919 99 int32_t x=128;
4920
4921 99 FFCore.warpScriptCheck();
4922
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 7920 times.
8019 for(int32_t i=0; i<80; i++)
4923 {
4924 7920 draw_screen(tmpscr);
4925 //? draw_screen already draws the subscreen -DD
4926 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4927 7920 x=128-(((i*128/80)/8)*8);
4928
4929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7920 times.
7920 if(x>0)
4930 {
4931 7920 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4932 7920 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4933 7920 }
4934
4935 7920 advanceframe(true);
4936
4937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7920 times.
7920 if(Quit)
4938 {
4939 break;
4940 }
4941 7920 }
4942
4943 99 Hero.setDontDraw(false);
4944 99 show_subscreen_items=true;
4945 99 show_subscreen_dmap_dots=true;
4946 726 }
4947
4948 void closescreen(int32_t shape)
4949 {
4950 reset_pal_cycling();
4951 black_opening_count=0;
4952
4953 if(COOLSCROLL || shape>-1)
4954 {
4955 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4956 return;
4957 }
4958 else
4959 {
4960 Hero.setDontDraw(true);
4961 show_subscreen_dmap_dots=false;
4962 show_subscreen_numbers=false;
4963 // show_subscreen_items=false;
4964 show_subscreen_life=false;
4965 }
4966
4967 int32_t x=128;
4968
4969 FFCore.warpScriptCheck();
4970 for(int32_t i=79; i>=0; --i)
4971 {
4972 draw_screen(tmpscr);
4973 //? draw_screen already draws the subscreen -DD
4974 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4975 x=128-(((i*128/80)/8)*8);
4976
4977 if(x>0)
4978 {
4979 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4980 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4981 }
4982
4983 advanceframe(true);
4984
4985 if(Quit)
4986 {
4987 break;
4988 }
4989 }
4990
4991 Hero.setDontDraw(false);
4992 show_subscreen_items=true;
4993 show_subscreen_dmap_dots=true;
4994 }
4995
4996 179 int32_t TriforceCount()
4997 {
4998 179 int32_t c=0;
4999
5000
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5001
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5002 1044 ++c;
5003
5004 179 return c;
5005 }
5006
5007 int32_t onCustomGame()
5008 {
5009 int32_t file = getsaveslot();
5010
5011 if(file < 0)
5012 return D_O_K;
5013
5014 bool ret = (custom_game(file)!=0);
5015 return ret ? D_CLOSE : D_O_K;
5016 }
5017
5018 int32_t onContinue()
5019 {
5020 return D_CLOSE;
5021 }
5022
5023 int32_t onEsc() // Unused?? -L
5024 {
5025 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5026 }
5027
5028 int32_t onVsync()
5029 {
5030 Throttlefps = !Throttlefps;
5031 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5032 return D_O_K;
5033 }
5034
5035 int32_t onWinPosSave()
5036 {
5037 SaveWinPos = !SaveWinPos;
5038 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5039 return D_O_K;
5040 }
5041 int32_t onIntegerScaling()
5042 {
5043 scaleForceInteger = !scaleForceInteger;
5044 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5045 return D_O_K;
5046 }
5047 int32_t onStretchGame()
5048 {
5049 stretchGame = !stretchGame;
5050 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5051 return D_O_K;
5052 }
5053
5054 int32_t onClickToFreeze()
5055 {
5056 ClickToFreeze = !ClickToFreeze;
5057 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5058 return D_O_K;
5059 }
5060
5061 int32_t OnSaveZCConfig()
5062 {
5063 if(jwin_alert3(
5064 "Save Configuration",
5065 "Are you sure that you wish to save your present configuration settings?",
5066 "This will overwrite your prior settings!",
5067 NULL,
5068 "&Yes",
5069 "&No",
5070 NULL,
5071 'y',
5072 'n',
5073 0,
5074 get_zc_font(font_lfont)) == 1)
5075 {
5076 save_game_configs();
5077 return D_O_K;
5078 }
5079 else return D_O_K;
5080 }
5081
5082 int32_t OnnClearQuestDir()
5083 {
5084 if(jwin_alert3(
5085 "Clear Current Directory Cache",
5086 "Are you sure that you wish to clear the current cached directory?",
5087 "This will default the current directory to the ROOT for this instance of ZC Player!",
5088 NULL,
5089 "&Yes",
5090 "&No",
5091 NULL,
5092 'y',
5093 'n',
5094 0,
5095 get_zc_font(font_lfont)) == 1)
5096 {
5097 zc_set_config("zeldadx","win_qst_dir","");
5098 flush_config_file();
5099 strcpy(qstdir,"");
5100 #ifdef __EMSCRIPTEN__
5101 em_sync_fs();
5102 #endif
5103 return D_O_K;
5104 }
5105 else return D_O_K;
5106 }
5107
5108
5109 int32_t onConsoleZASM()
5110 {
5111 if ( !zasm_debugger )
5112 {
5113 AlertDialog("WARNING: ZASM Debugger",
5114 "Enabling this will open the ZASM Debugger Console"
5115 "\nThis will likely grind ZC to a halt with lag."
5116 "\nTo make any use of this, it is suggested that you read"
5117 "\nthe documentation for 'void Breakpoint(char[] string);'"
5118 " in 'ZScript_Additions.txt'"
5119 "\nThis is not recommended for normal users,"
5120 " and is only intended for ZC developers,"
5121 "\nor quest developers coding directly in ZASM"
5122 "\nAre you sure that you wish to open the ZASM Debugger?",
5123 [&](bool ret,bool)
5124 {
5125 if(ret)
5126 {
5127 FFCore.ZASMPrint(true);
5128 }
5129 }).show();
5130 return D_O_K;
5131 }
5132 else
5133 {
5134 FFCore.ZASMPrint(false);
5135 return D_O_K;
5136 }
5137 }
5138
5139
5140 int32_t onConsoleZScript()
5141 {
5142 if ( !zscript_debugger )
5143 {
5144 AlertDialog("ZScript Debugger",
5145 "Enabling this will open the ZScript Debugger Console"
5146 "\nThis will display any messages logged by scripts,"
5147 " including script errors."
5148 "\nAre you sure that you wish to open the ZScript Debugger?",
5149 [&](bool ret,bool)
5150 {
5151 if(ret)
5152 {
5153 FFCore.ZScriptConsole(true);
5154 }
5155 }).show();
5156 return D_O_K;
5157 }
5158 else
5159 {
5160 FFCore.ZScriptConsole(false);
5161 return D_O_K;
5162 }
5163 }
5164
5165 int32_t onClrConsoleOnReload()
5166 {
5167 clearConsoleOnReload = !clearConsoleOnReload;
5168 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5169 return D_O_K;
5170 }
5171 int32_t onClrConsoleOnLoad()
5172 {
5173 clearConsoleOnLoad = !clearConsoleOnLoad;
5174 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5175 return D_O_K;
5176 }
5177
5178
5179 int32_t onFrameSkip()
5180 {
5181 FrameSkip = !FrameSkip;
5182 return D_O_K;
5183 }
5184
5185 int32_t onSaveDragResize()
5186 {
5187 SaveDragResize = !SaveDragResize;
5188 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5189 return D_O_K;
5190 }
5191
5192 int32_t onDragAspect()
5193 {
5194 DragAspect = !DragAspect;
5195 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5196 return D_O_K;
5197 }
5198
5199 int32_t onTransLayers()
5200 {
5201 TransLayers = !TransLayers;
5202 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5203 return D_O_K;
5204 }
5205
5206 int32_t onNESquit()
5207 {
5208 NESquit = !NESquit;
5209 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5210 return D_O_K;
5211 }
5212
5213 int32_t onVolKeys()
5214 {
5215 volkeys = !volkeys;
5216 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5217 return D_O_K;
5218 }
5219
5220 int32_t onShowFPS()
5221 {
5222 ShowFPS = !ShowFPS;
5223 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5224 return D_O_K;
5225 }
5226
5227 957457546 bool is_Fkey(int32_t k)
5228 {
5229
2/2
✓ Branch 0 taken 97368564 times.
✓ Branch 1 taken 860088982 times.
957457546 switch(k)
5230 {
5231 case KEY_F1:
5232 case KEY_F2:
5233 case KEY_F3:
5234 case KEY_F4:
5235 case KEY_F5:
5236 case KEY_F6:
5237 case KEY_F7:
5238 case KEY_F8:
5239 case KEY_F9:
5240 case KEY_F10:
5241 case KEY_F11:
5242 case KEY_F12:
5243 97368564 return true;
5244 }
5245
5246 860088982 return false;
5247 957457546 }
5248
5249 void kb_getkey(DIALOG *d);
5250
5251 //Used by all keyboard key settings dialogues.
5252 void kb_clearjoystick(DIALOG *d)
5253 {
5254 d->flags|=D_SELECTED;
5255
5256 jwin_button_proc(MSG_DRAW,d,0);
5257 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5258 // text_mode(vc(11));
5259 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5260 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5261
5262 update_hw_screen(true);
5263
5264 clear_keybuf();
5265 int32_t k = next_press_key();
5266 clear_keybuf();
5267
5268 //shnarf
5269 //47=f1
5270 //59=esc
5271 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5272 // *((int32_t*)d->dp3) = k;
5273 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5274
5275
5276 d->flags&=~D_SELECTED;
5277 }
5278
5279 //Clears key to 0.
5280 //Used by all keyboard key settings dialogues.
5281 void kb_clearkey(DIALOG *d);
5282
5283 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5284 {
5285 switch(msg)
5286 {
5287 case MSG_KEY:
5288 case MSG_CLICK:
5289
5290 kb_clearjoystick(d);
5291
5292 while(gui_mouse_b())
5293 {
5294 clear_keybuf();
5295 rest(1);
5296 }
5297
5298 return D_REDRAW;
5299 }
5300
5301 return jwin_button_proc(msg,d,c);
5302 }
5303
5304 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5305 //Only used in keyboard settings dialogues to clear keys.
5306 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5307
5308 void j_getbtn(DIALOG *d)
5309 {
5310 d->flags|=D_SELECTED;
5311 jwin_button_proc(MSG_DRAW,d,0);
5312 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5313 // text_mode(vc(11));
5314 int32_t y = gui_bmp->h/2 - 12;
5315 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5316 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5317 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5318
5319 update_hw_screen(true);
5320
5321 int32_t b = next_press_btn();
5322
5323 if(b>=0)
5324 *((int32_t*)d->dp3) = b;
5325
5326 d->flags&=~D_SELECTED;
5327
5328 if (player)
5329 player->joy_on = TRUE;
5330 }
5331
5332 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5333 {
5334 switch(msg)
5335 {
5336 case MSG_KEY:
5337 case MSG_CLICK:
5338
5339 j_getbtn(d);
5340
5341 while(gui_mouse_b()) {
5342 rest(1);
5343 clear_keybuf();
5344 }
5345
5346 return D_REDRAW;
5347 }
5348
5349 return jwin_button_proc(msg,d,c);
5350 }
5351
5352 //shnarf
5353 extern const char *key_str[];
5354 std::string get_keystr(int key);
5355
5356 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5357 //extern int32_t zcmusic_bufsz;
5358
5359 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5360 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5361
5362 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5363 {
5364 //these are here to bypass compiler warnings about unused arguments
5365 c=c;
5366
5367 if(msg==MSG_DRAW)
5368 {
5369 switch(d->w)
5370 {
5371 case 0:
5372 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5373 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5374 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5375 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5376 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5377 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5378 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5379 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5380 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5381 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5382 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5383 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5384 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5385 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5386 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5387 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5388 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5389 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5390 break;
5391
5392 case 1:
5393 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5394 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5395 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5396 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5397 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5398 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5399 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5400 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5401 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5402 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5403 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5404 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5405 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5406 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5407 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5408 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5409 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5410 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5411 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5412 break;
5413
5414 case 2:
5415 sprintf(str_a," %3d",midi_volume);
5416 sprintf(str_b," %3d",digi_volume);
5417 sprintf(str_l," %3d",emusic_volume);
5418 sprintf(str_m," %3dKB",zcmusic_bufsz);
5419 sprintf(str_r," %3d",sfx_volume);
5420 strcpy(str_s,pan_str[pan_style]);
5421 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5422 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5423 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5424 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5425 break;
5426 }
5427 }
5428
5429 return D_O_K;
5430 }
5431
5432 int32_t set_vol(void *dp3, int32_t d2)
5433 {
5434 switch(((int32_t*)dp3)[0])
5435 {
5436 case 0:
5437 midi_volume = zc_min(d2<<3,255);
5438 break;
5439
5440 case 1:
5441 digi_volume = zc_min(d2<<3,255);
5442 break;
5443
5444 case 2:
5445 emusic_volume = zc_min(d2<<3,255);
5446 break;
5447
5448 case 3:
5449 sfx_volume = zc_min(d2<<3,255);
5450 break;
5451 }
5452
5453 // text_mode(vc(11));
5454 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5455 return D_O_K;
5456 }
5457
5458 int32_t set_pan(void *dp3, int32_t d2)
5459 {
5460 pan_style = vbound(d2,0,3);
5461 // text_mode(vc(11));
5462 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5463 return D_O_K;
5464 }
5465
5466 int32_t set_buf(void *dp3, int32_t d2)
5467 {
5468 // text_mode(vc(11));
5469 zcmusic_bufsz = d2 + 1;
5470 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5471 return D_O_K;
5472 }
5473
5474 static int32_t gamepad_btn_list[] =
5475 {
5476 6,
5477 7,8,9,10,11,12,13,14,15,16,17,
5478 18,19,20,21,22,23,24,25,26,27,28,
5479 29,30,31,32,33,34,35,36,37,38,39,
5480 -1
5481 };
5482
5483 static int32_t gamepad_dirs_list[] =
5484 {
5485 40,41,42,43,
5486 44,45,46,47,
5487 48,49,50,51,
5488 52,53,54,55,
5489 56,
5490 -1
5491 };
5492
5493 static TABPANEL gamepad_tabs[] =
5494 {
5495 // (text)
5496 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5497 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5498 { NULL, 0, NULL, 0, NULL }
5499 };
5500
5501 static DIALOG gamepad_dlg[] =
5502 {
5503 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5504 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5505 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5506 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5507 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5508 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5509 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5510 // 6
5511 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5512 // 7
5513 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5514 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5515 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5516 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5517 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5518 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5519 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5520 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5521 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5522 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5523 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5524 // 18
5525 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5526 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5527 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5528 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5529 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5530 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5531 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5532 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5533 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5534 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5535 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5536 // 29
5537 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5538 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5539 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5540 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5541 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5542 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5543 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5544 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5545 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5546 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5547 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5548 // 40
5549 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5550 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5551 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5552 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5553 // 44
5554 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5555 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5556 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5557 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5558 // 48
5559 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5560 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5561 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5562 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5563 // 52
5564 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5565 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5566 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5567 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5568 // 56
5569 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5570 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5571 };
5572
5573 static int32_t keyboard_keys_list[] =
5574 {
5575 6,7,8,9,10,
5576 11,12,13,14,15,16,17,18,19,20,
5577 21,22,23,24,25,26,27,28,29,30,
5578 31,32,33,34,35,36,37,38,39,40,
5579 -1
5580 };
5581
5582 static int32_t keyboard_dirs_list[] =
5583 {
5584 41,42,43,44,
5585 45,46,47,48,
5586 49,50,51,52,
5587 53,54,55,56,
5588 -1
5589 };
5590
5591 static int32_t keyboard_mods_list[] =
5592 {
5593 57,58,59,60,
5594 61,62,63,64,
5595 65,66,67,68,
5596 69,70,71,72,
5597 -1
5598 };
5599
5600 static TABPANEL keyboard_control_tabs[] =
5601 {
5602 // (text)
5603 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5604 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5605 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5606 { NULL, 0, NULL, 0, NULL }
5607 };
5608
5609 static DIALOG keyboard_control_dlg[] =
5610 {
5611 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5612 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5613 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5614 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5615 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5616 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5617 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5618 // Keys
5619 // 6
5620 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5621 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5622 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5623 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5624 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5625 // 11
5626 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5627 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5628 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5629 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5630 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5631 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5632 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5633 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5634 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5635 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5636 // 21
5637 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5638 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5639 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5640 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5641 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5642 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5643 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5644 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5645 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5646 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5647 // 31
5648 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5649 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5650 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5651 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5652 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5653 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5654 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5655 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5656 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5657 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5658 // Dirs
5659 // 41
5660 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5661 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5662 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5663 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5664 // 45
5665 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5666 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5667 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5668 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5669 // 49
5670 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5671 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5672 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5673 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5674 // 53
5675 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5676 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5677 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5678 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5679 // Mods
5680 // 57
5681 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5682 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5683 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5684 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5685 // 61
5686 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5687 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5688 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5689 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5690 // 65
5691 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5692 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5693 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5694 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5695 // 69
5696 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5697 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5698 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5699 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5700 // 73
5701 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5702 };
5703
5704 /*
5705 int32_t midi_dp[3] = {0,147,104};
5706 int32_t digi_dp[3] = {1,147,120};
5707 int32_t pan_dp[3] = {0,147,136};
5708 int32_t buf_dp[3] = {0,147,152};
5709 */
5710 int32_t midi_dp[3] = {0,0,0};
5711 int32_t digi_dp[3] = {1,0,0};
5712 int32_t emus_dp[3] = {2,0,0};
5713 int32_t buf_dp[3] = {0,0,0};
5714 int32_t sfx_dp[3] = {3,0,0};
5715 int32_t pan_dp[3] = {0,0,0};
5716
5717 static DIALOG sound_dlg[] =
5718 {
5719 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5720 36 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5721 36 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5722 36 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5723 36 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5724 36 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5725 36 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5726 36 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5727 36 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5728 36 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5729 36 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5730 // 10
5731 36 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5732 36 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5733 36 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5734 36 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5735 36 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5736 36 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5737 36 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5738 36 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5739 36 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5740 36 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5741 //20
5742 36 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5743 36 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5744 36 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5745 36 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5746 36 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5747 36 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5748 36 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5749 36 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5750 36 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5751 36 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5752 //30
5753 36 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5754 36 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5755 36 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5756 36 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5757 };
5758
5759 char zc_builddate[80];
5760 char zc_aboutstr[80];
5761
5762 static DIALOG about_dlg[] =
5763 {
5764 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5765 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5766 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5767 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5768 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5769 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5770 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5771 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5772 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5773 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5774 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5775 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5776 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5777 };
5778
5779
5780 static DIALOG quest_dlg[] =
5781 {
5782 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5783 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5784 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5785 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5786 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5787 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5788 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5789 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5790 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5791 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5792 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5793 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5794 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5795 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5796 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5797 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5798 };
5799
5800 static DIALOG triforce_dlg[] =
5801 {
5802 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5803 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5804 // 1
5805 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5806 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5807 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5808 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5809 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5810 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5811 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5812 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5813 // 9
5814 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5815 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5816 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5817 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5818 };
5819
5820 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5821 {
5822 go();
5823 int32_t ret=0;
5824 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5825 comeback();
5826 return ret != 0;
5827 }
5828
5829
5830 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5831 {
5832 if(def!=modulepath)
5833 strcpy(modulepath,def);
5834
5835 if(!usefilename)
5836 {
5837 int32_t i=(int32_t)strlen(modulepath);
5838
5839 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5840 modulepath[i--]=0;
5841 }
5842
5843 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5844 int32_t ret=0;
5845 int32_t sel=0;
5846
5847 if(list==NULL)
5848 {
5849 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5850 }
5851 else
5852 {
5853 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5854 }
5855
5856 return ret!=0;
5857 }
5858
5859 //The Dialogue that loads a ZMOD Module File
5860 int32_t zc_load_zmod_module_file()
5861 {
5862 if ( Playing )
5863 {
5864 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5865 return -1;
5866 }
5867 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5868 return D_CLOSE;
5869
5870 FILE *tempmodule = fopen(modulepath,"r");
5871
5872 if(tempmodule == NULL)
5873 {
5874 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5875 return -1;
5876 }
5877
5878
5879 //Set the module path:
5880 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
5881 strcpy(moduledata.module_name, modulepath);
5882 al_trace("New Module Path is: %s \n", moduledata.module_name);
5883 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
5884 zcm.init(true); //Load the module values.
5885 moduledata.refresh_title_screen = 1;
5886 // refresh_select_screen = 1;
5887 build_biic_list();
5888 return D_O_K;
5889 }
5890
5891 static DIALOG module_info_dlg[] =
5892 {
5893 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
5894
5895
5896 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
5897 //1
5898 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
5899 //2
5900 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5901 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
5902 //4
5903 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5904 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5905 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
5906 //7
5907
5908 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5909 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5910 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5911 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5912 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5913 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5914 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5915 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5916 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5917
5918 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5919 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5920 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5921 };
5922
5923 void about_zcplayer_module(const char *prompt,int32_t initialval)
5924 {
5925
5926 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
5927 if ( moduledata.moduletitle[0] != 0 )
5928 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
5929
5930 if ( moduledata.moduleauthor[0] != 0 )
5931 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
5932
5933 if ( moduledata.moduleinfo0[0] != 0 )
5934 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
5935 if ( moduledata.moduleinfo1[0] != 0 )
5936 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
5937 if ( moduledata.moduleinfo2[0] != 0 )
5938 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
5939 if ( moduledata.moduleinfo3[0] != 0 )
5940 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
5941 if ( moduledata.moduleinfo4[0] != 0 )
5942 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
5943
5944 char module_date[255];
5945 memset(module_date, 0, sizeof(module_date));
5946 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
5947 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
5948
5949
5950
5951 char module_vers[255];
5952 memset(module_vers, 0, sizeof(module_vers));
5953 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
5954
5955
5956 //sprintf(tilecount,"%d",1);
5957
5958 char module_build[255];
5959 memset(module_build, 0, sizeof(module_build));
5960 if ( moduledata.modbeta )
5961 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
5962 else
5963 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
5964
5965 module_info_dlg[12].dp = (char*)module_date;
5966 module_info_dlg[13].dp = (char*)module_vers;
5967 module_info_dlg[14].dp = (char*)module_build;
5968
5969 large_dialog(module_info_dlg);
5970
5971 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
5972 jwin_center_dialog(module_info_dlg);
5973
5974
5975 }
5976
5977 int32_t onAbout_ZCP_Module()
5978 {
5979 about_zcplayer_module("About Module (.zmod)", 0);
5980 return D_O_K;
5981 }
5982
5983 //New Modules Menu for 2.55+
5984 static MENU zcmodule_menu[] =
5985 {
5986 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
5987 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
5988
5989 { NULL, NULL, NULL, 0, NULL }
5990 };
5991
5992 int32_t onToggleRecordingNewSaves()
5993 {
5994 if (zc_get_config("zeldadx", "replay_new_saves", false))
5995 {
5996 zc_set_config("zeldadx", "replay_new_saves", false);
5997 }
5998 else
5999 {
6000 zc_set_config("zeldadx", "replay_new_saves", true);
6001 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6002 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6003 }
6004 return D_O_K;
6005 }
6006
6007 int32_t onToggleSnapshotAllFrames()
6008 {
6009 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6010 return D_O_K;
6011 }
6012
6013 int32_t onStopReplayOrRecord()
6014 {
6015 if (replay_is_replaying())
6016 {
6017 replay_quit();
6018 }
6019 else if (replay_get_mode() == ReplayMode::Record)
6020 {
6021 if (!replay_get_meta_bool("test_mode"))
6022 {
6023 jwin_alert("Recording", "You cannot stop recording a save file.",
6024 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6025 return D_CLOSE;
6026 }
6027
6028 if (jwin_alert("Stop Recording",
6029 "Save replay to disk and stop recording?",
6030 "This will stop the recording.",
6031 NULL,
6032 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6033 return D_CLOSE;
6034
6035 replay_save();
6036 replay_stop();
6037 }
6038 return D_O_K;
6039 }
6040
6041 static int32_t handle_on_load_replay(ReplayMode mode)
6042 {
6043 if (Playing)
6044 {
6045 if (jwin_alert("Replay - Warning!",
6046 "Loading a replay will exit the current game.",
6047 "All unsaved progress will be lost.",
6048 "Do you wish to continue?",
6049 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6050 return D_CLOSE;
6051 }
6052
6053 std::string mode_string = replay_mode_to_string(mode);
6054 mode_string[0] = std::toupper(mode_string[0]);
6055
6056 std::string line_1 = "Select a replay file to play back.";
6057 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6058 std::string line_3 = "You can stop the replay and take over manually any time.";
6059 if (mode == ReplayMode::Update)
6060 {
6061 line_1 = "Select a replay file to update.";
6062 line_2 = "WARNING: be sure to back up the zplay file";
6063 line_3 = "and verify that the updated replay works as expected!";
6064 }
6065
6066 if (jwin_alert(mode_string.c_str(),
6067 line_1.c_str(),
6068 line_2.c_str(),
6069 line_3.c_str(),
6070 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6071 {
6072 char replay_path[2048];
6073 strcpy(replay_path, "replays/");
6074 if (jwin_file_select_ex(
6075 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6076 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6077 return D_CLOSE;
6078
6079 replay_quit();
6080 load_replay_file_deferred(mode, replay_path);
6081 Quit = qRESET;
6082 return D_CLOSE;
6083 }
6084 return D_O_K;
6085 }
6086
6087 int32_t onLoadReplay()
6088 {
6089 return handle_on_load_replay(ReplayMode::Replay);
6090 }
6091
6092 int32_t onLoadReplayAssert()
6093 {
6094 return handle_on_load_replay(ReplayMode::Assert);
6095 }
6096
6097 int32_t onLoadReplayUpdate()
6098 {
6099 return handle_on_load_replay(ReplayMode::Update);
6100 }
6101
6102 int32_t onSaveReplay()
6103 {
6104 if (replay_get_mode() == ReplayMode::Record)
6105 {
6106 if (!replay_get_meta_bool("test_mode"))
6107 {
6108 if (jwin_alert("Save Replay",
6109 "This will save a copy of the replay up to this point.",
6110 "The official replay file will be untouched.",
6111 "Do you wish to continue?",
6112 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6113 return D_CLOSE;
6114
6115 char replay_path[2048];
6116 strcpy(replay_path, replay_get_replay_path().string().c_str());
6117 if (jwin_file_select_ex(
6118 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6119 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6120 return D_CLOSE;
6121
6122 if (fileexists(replay_path))
6123 {
6124 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6125 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6126 return D_CLOSE;
6127 }
6128
6129 replay_save(replay_path);
6130 }
6131 else
6132 {
6133 replay_save();
6134 }
6135 }
6136 return D_O_K;
6137 }
6138
6139 static MENU replay_menu[] =
6140 {
6141 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6142 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6143 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6144 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6145 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6146 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6147 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6148
6149 { NULL, NULL, NULL, 0, NULL }
6150 };
6151
6152 static DIALOG credits_dlg[] =
6153 {
6154 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6155 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6156 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6157 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6158 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6159 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6160 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6161 };
6162
6163 36 static ListData dmap_list(dmaplist, &font);
6164
6165 static DIALOG goto_dlg[] =
6166 {
6167 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6168 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6169 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6170 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6171 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6172 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6173 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6174 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6175 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6176 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6177 };
6178
6179 int32_t onGoTo()
6180 {
6181 bool music = false;
6182 music = music;
6183 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6184
6185 goto_dlg[0].dp2=get_zc_font(font_lfont);
6186 goto_dlg[4].d2=cheat_goto_dmap;
6187 goto_dlg[6].dp=cheat_goto_screen_str;
6188
6189 clear_keybuf();
6190
6191 large_dialog(goto_dlg);
6192
6193 if(zc_popup_dialog(goto_dlg,4)==1)
6194 {
6195 // dmap, screen
6196 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6197 };
6198
6199 return D_O_K;
6200 }
6201
6202 int32_t onGoToComplete()
6203 {
6204 if(!Playing)
6205 {
6206 return D_O_K;
6207 }
6208
6209 enter_sys_pal();
6210 music_pause();
6211 pause_all_sfx();
6212 onGoTo();
6213 eat_buttons();
6214
6215 zc_readrawkey(KEY_ESC);
6216
6217 exit_sys_pal();
6218 music_resume();
6219 resume_all_sfx();
6220 return D_O_K;
6221 }
6222
6223 int32_t onCredits()
6224 {
6225 go();
6226
6227 BITMAP *win = create_bitmap_ex(8,222,110);
6228
6229 if(!win)
6230 return D_O_K;
6231
6232 int32_t c=0;
6233 int32_t l=0;
6234 int32_t ol=-1;
6235 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6236 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6237 PALETTE tmppal;
6238
6239 rti_gui.transparency_index = 1;
6240
6241 clear_to_color(win, rti_gui.transparency_index);
6242 draw_rle_sprite(win,rle,0,0);
6243 credits_dlg[0].dp2=get_zc_font(font_lfont);
6244 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6245 credits_dlg[2].dp = win;
6246
6247 zc_set_palette_range(black_palette,0,127,false);
6248
6249 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6250
6251 BITMAP* old_screen = screen;
6252 BITMAP* gui_bmp = zc_get_gui_bmp();
6253 ASSERT(gui_bmp);
6254 clear_to_color(gui_bmp, rti_gui.transparency_index);
6255 screen = gui_bmp;
6256
6257 while(update_dialog(p))
6258 {
6259 throttleFPS();
6260 ++c;
6261 l = zc_max((c>>1)-30,0);
6262
6263 if(l > rle->h)
6264 l = c = 0;
6265
6266 if(l > rle->h - 112)
6267 l = rle->h - 112;
6268
6269 clear_bitmap(win);
6270 draw_rle_sprite(win,rle,0,0-l);
6271
6272 if(c<=64)
6273 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6274
6275 zc_set_palette_range(tmppal,0,127,false);
6276
6277 if(l!=ol)
6278 {
6279 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6280 SCRFIX();
6281 ol=l;
6282 }
6283
6284 update_hw_screen();
6285 }
6286
6287 screen = old_screen;
6288 system_pal(true);
6289 sys_mouse();
6290
6291 shutdown_dialog(p);
6292 destroy_bitmap(win);
6293 //comeback();
6294
6295 rti_gui.transparency_index = 0;
6296 clear_to_color(gui_bmp, rti_gui.transparency_index);
6297
6298 return D_O_K;
6299 }
6300
6301 const char *midilist(int32_t index, int32_t *list_size)
6302 {
6303 if(index<0)
6304 {
6305 *list_size=0;
6306
6307 for(int32_t i=0; i<MAXMIDIS; i++)
6308 if(tunes[i].data)
6309 ++(*list_size);
6310
6311 return NULL;
6312 }
6313
6314 int32_t i=0,m=0;
6315
6316 while(m<=index && i<=MAXMIDIS)
6317 {
6318 if(tunes[i].data)
6319 ++m;
6320
6321 ++i;
6322 }
6323
6324 --i;
6325
6326 if(i==MAXMIDIS && m<index)
6327 return "(null)";
6328
6329 return tunes[i].title;
6330 }
6331
6332 /* ------- MIDI info stuff -------- */
6333
6334 char *text;
6335 midi_info *zmi;
6336 bool dialog_running;
6337 bool listening;
6338
6339 void get_info(int32_t index);
6340
6341 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6342 {
6343 int32_t d2 = d->d2;
6344 int32_t ret = jwin_droplist_proc(msg,d,c);
6345
6346 if(d2!=d->d2)
6347 {
6348 get_info(d->d2);
6349 }
6350
6351 return ret;
6352 }
6353
6354 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6355 {
6356 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6357
6358 int32_t ret = jwin_button_proc(msg,d,c);
6359
6360 if(ret == D_CLOSE)
6361 {
6362 // get current midi index
6363 int32_t index = (d+(d->d1))->d2;
6364 int32_t i=0, m=0;
6365
6366 while(m<=index && i<=MAXMIDIS)
6367 {
6368 if(tunes[i].data)
6369 ++m;
6370
6371 ++i;
6372 }
6373
6374 --i;
6375 jukebox(i);
6376 listening = true;
6377 ret = D_O_K;
6378 }
6379
6380 return ret;
6381 }
6382
6383 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6384 {
6385 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6386
6387 int32_t ret = jwin_button_proc(msg,d,c);
6388
6389 if(ret == D_CLOSE)
6390 {
6391 // get current midi index
6392 int32_t index = (d+(d->d1))->d2;
6393 int32_t i=0, m=0;
6394
6395 while(m<=index && i<=MAXMIDIS)
6396 {
6397 if(tunes[i].data)
6398 ++m;
6399
6400 ++i;
6401 }
6402
6403 --i;
6404
6405 // get file name
6406
6407 int32_t sel=0;
6408 //struct ffblk f;
6409 char title[40] = "Save MIDI: ";
6410 char fname[2048];
6411 memset(fname,0,2048);
6412 static EXT_LIST list[] =
6413 {
6414 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6415 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6416 { NULL, NULL }
6417 };
6418
6419 strcpy(title+11, tunes[i].title);
6420 title[39] = '\0';
6421
6422 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6423 goto done;
6424
6425 if(exists(fname))
6426 {
6427 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6428 goto done;
6429 }
6430
6431 // save midi i
6432
6433 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6434 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6435
6436 done:
6437 chop_path(fname);
6438 ret = D_REDRAW;
6439 }
6440
6441 return ret;
6442 }
6443
6444 36 static ListData midi_list(midilist, &font);
6445
6446 static DIALOG midi_dlg[] =
6447 {
6448 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6449 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6450 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6451 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6452 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6453 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6454 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6455 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6456 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6457 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6458 };
6459
6460 void get_info(int32_t index)
6461 {
6462 int32_t i=0, m=0;
6463
6464 while(m<=index && i<=MAXMIDIS)
6465 {
6466 if(tunes[i].data)
6467 ++m;
6468
6469 ++i;
6470 }
6471
6472 --i;
6473
6474 if(i==MAXMIDIS && m<index)
6475 strcpy(text,"(null)");
6476 else
6477 {
6478 get_midi_info((MIDI*)tunes[i].data,zmi);
6479 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6480 }
6481
6482 midi_dlg[0].dp2=get_zc_font(font_lfont);
6483 midi_dlg[3].dp = text;
6484 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6485 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6486
6487 if(dialog_running)
6488 {
6489 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6490 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6491 }
6492 }
6493
6494 int32_t onMIDICredits()
6495 {
6496 text = (char*)malloc(4096);
6497 zmi = (midi_info*)malloc(sizeof(midi_info));
6498
6499 if(!text || !zmi)
6500 {
6501 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6502 return D_O_K;
6503 }
6504
6505 bool do_pause_midi = midi_pos >= 0 && currmidi;
6506 auto restore_midi = currmidi;
6507 if(do_pause_midi)
6508 {
6509 paused_midi_pos = midi_pos;
6510 stop_midi();
6511 midi_paused=true;
6512 midi_suspended = midissuspHALTED;
6513 }
6514
6515 midi_dlg[0].dp2=get_zc_font(font_lfont);
6516 midi_dlg[2].d1 = 0;
6517 midi_dlg[2].d2 = 0;
6518 midi_dlg[4].flags = D_EXIT;
6519 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6520
6521 listening = false;
6522 dialog_running=false;
6523 get_info(0);
6524
6525 dialog_running=true;
6526
6527 large_dialog(midi_dlg);
6528
6529 zc_popup_dialog(midi_dlg,0);
6530 dialog_running=false;
6531
6532 if(listening)
6533 music_stop();
6534
6535 if(do_pause_midi)
6536 {
6537 midi_suspended = midissuspRESUME;
6538 currmidi = restore_midi;
6539 midi_pos = paused_midi_pos;
6540 }
6541
6542 if(text) free(text);
6543 if(zmi) free(zmi);
6544 return D_O_K;
6545 }
6546
6547 int32_t onAbout()
6548 {
6549 char buf1[80]={0};
6550 std::ostringstream oss;
6551 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6552 oss << buf1 << '\n';
6553 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6554 oss << buf1 << '\n';
6555 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6556 oss << buf1 << '\n';
6557 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6558 oss << buf1 << '\n';
6559 sprintf(buf1, "Tag: %s", getReleaseTag());
6560 oss << buf1 << '\n';
6561
6562 InfoDialog("About ZC", oss.str()).show();
6563 return D_O_K;
6564 }
6565
6566 int32_t onQuest()
6567 {
6568 char fname[100];
6569 strcpy(fname, get_filename(qstpath));
6570 quest_dlg[0].dp2=get_zc_font(font_lfont);
6571 quest_dlg[1].dp = fname;
6572
6573 if(QHeader.quest_number==0)
6574 sprintf(str_a,"Custom");
6575 else
6576 sprintf(str_a,"%d",QHeader.quest_number);
6577
6578 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6579
6580 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6581 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6582
6583 large_dialog(quest_dlg);
6584
6585 zc_popup_dialog(quest_dlg, 0);
6586 return D_O_K;
6587 }
6588
6589 void call_vidmode_dlg();
6590 int32_t onVidMode()
6591 {
6592 call_vidmode_dlg();
6593 return D_O_K;
6594 }
6595
6596 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6597 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6598 //Added an extra statement, so that if the key is cleared to 0, the cleared
6599 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6600
6601 void load_ukeys(int32_t* arr)
6602 {
6603 arr[ukey_a] = Akey;
6604 arr[ukey_b] = Bkey;
6605 arr[ukey_s] = Skey;
6606 arr[ukey_l] = Lkey;
6607 arr[ukey_r] = Rkey;
6608 arr[ukey_p] = Pkey;
6609 arr[ukey_ex1] = Exkey1;
6610 arr[ukey_ex2] = Exkey2;
6611 arr[ukey_ex3] = Exkey3;
6612 arr[ukey_ex4] = Exkey4;
6613 arr[ukey_du] = DUkey;
6614 arr[ukey_dd] = DDkey;
6615 arr[ukey_dl] = DLkey;
6616 arr[ukey_dr] = DRkey;
6617 arr[ukey_mod1a] = cheat_modifier_keys[0];
6618 arr[ukey_mod1b] = cheat_modifier_keys[1];
6619 arr[ukey_mod2a] = cheat_modifier_keys[2];
6620 arr[ukey_mod2b] = cheat_modifier_keys[3];
6621 };
6622
6623 static const char* ukey_names[] = {
6624 "A", "B", "Start", "L", "R", "Map",
6625 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6626 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6627 "Cheat Mod R1", "Cheat Mod R2",
6628 };
6629 std::string get_ukey_name(int32_t k)
6630 {
6631 if (k < num_ukey) return ukey_names[k];
6632 return "";
6633 }
6634
6635 int32_t onKeyboard()
6636 {
6637 int32_t a = Akey;
6638 int32_t b = Bkey;
6639 int32_t s = Skey;
6640 int32_t l = Lkey;
6641 int32_t r = Rkey;
6642 int32_t p = Pkey;
6643 int32_t ex1 = Exkey1;
6644 int32_t ex2 = Exkey2;
6645 int32_t ex3 = Exkey3;
6646 int32_t ex4 = Exkey4;
6647 int32_t du = DUkey;
6648 int32_t dd = DDkey;
6649 int32_t dl = DLkey;
6650 int32_t dr = DRkey;
6651 int32_t mod1a = cheat_modifier_keys[0];
6652 int32_t mod1b = cheat_modifier_keys[1];
6653 int32_t mod2a = cheat_modifier_keys[2];
6654 int32_t mod2b = cheat_modifier_keys[3];
6655 bool done=false;
6656 int32_t ret;
6657
6658 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6659
6660 large_dialog(keyboard_control_dlg);
6661
6662 while(!done)
6663 {
6664 ret = zc_popup_dialog(keyboard_control_dlg,3);
6665
6666 if(ret==3) // OK
6667 {
6668 int32_t ukeys[num_ukey];
6669 load_ukeys(ukeys);
6670 std::vector<std::string> uniqueError;
6671 for(int32_t q = 0; q < num_ukey; ++q)
6672 {
6673 for(int32_t p = q+1; p < num_ukey; ++p)
6674 {
6675 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6676 {
6677 char buf[64];
6678 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6679 std::string str(buf);
6680 uniqueError.push_back(str);
6681 }
6682 }
6683 }
6684 if(uniqueError.size() == 0)
6685 {
6686 done = true;
6687 save_control_configs(true);
6688 }
6689 else
6690 {
6691 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6692 box_out("Cannot have duplicate keybinds!"); box_eol();
6693 for(std::vector<std::string>::iterator it = uniqueError.begin();
6694 it != uniqueError.end(); ++it)
6695 {
6696 box_out((*it).c_str()); box_eol();
6697 }
6698 box_end(true);
6699 }
6700 }
6701 else // Cancel
6702 {
6703 Akey = a;
6704 Bkey = b;
6705 Skey = s;
6706 Lkey = l;
6707 Rkey = r;
6708 Pkey = p;
6709 Exkey1 = ex1;
6710 Exkey2 = ex2;
6711 Exkey3 = ex3;
6712 Exkey4 = ex4;
6713 DUkey = du;
6714 DDkey = dd;
6715 DLkey = dl;
6716 DRkey = dr;
6717 cheat_modifier_keys[0] = mod1a;
6718 cheat_modifier_keys[1] = mod1b;
6719 cheat_modifier_keys[2] = mod2a;
6720 cheat_modifier_keys[3] = mod2b;
6721
6722 done=true;
6723 }
6724
6725 rest(1);
6726 }
6727
6728 return D_O_K;
6729 }
6730
6731 int32_t onGamepad()
6732 {
6733 int32_t a = Abtn;
6734 int32_t b = Bbtn;
6735 int32_t s = Sbtn;
6736 int32_t l = Lbtn;
6737 int32_t r = Rbtn;
6738 int32_t m = Mbtn;
6739 int32_t p = Pbtn;
6740 int32_t ex1 = Exbtn1;
6741 int32_t ex2 = Exbtn2;
6742 int32_t ex3 = Exbtn3;
6743 int32_t ex4 = Exbtn4;
6744 int32_t up = DUbtn;
6745 int32_t down = DDbtn;
6746 int32_t left = DLbtn;
6747 int32_t right = DRbtn;
6748
6749 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6750 if(analog_movement)
6751 gamepad_dlg[56].flags|=D_SELECTED;
6752 else
6753 gamepad_dlg[56].flags&=~D_SELECTED;
6754
6755 large_dialog(gamepad_dlg);
6756
6757 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6758
6759 if(ret == 4) //OK
6760 {
6761 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6762 save_control_configs(false);
6763 }
6764 else //Cancel
6765 {
6766 Abtn = a;
6767 Bbtn = b;
6768 Sbtn = s;
6769 Lbtn = l;
6770 Rbtn = r;
6771 Mbtn = m;
6772 Pbtn = p;
6773 Exbtn1 = ex1;
6774 Exbtn2 = ex2;
6775 Exbtn3 = ex3;
6776 Exbtn4 = ex4;
6777 DUbtn = up;
6778 DDbtn = down;
6779 DLbtn = left;
6780 DRbtn = right;
6781 }
6782
6783 return D_O_K;
6784 }
6785
6786 int32_t onCheatKeys()
6787 {
6788 int32_t oldcheats[Cheat::Last][2];
6789 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6790
6791 bool done=false;
6792
6793 while(!done)
6794 {
6795 bool confirm = false;
6796 CheatKeysDialog(&confirm).show();
6797 if(confirm) // OK
6798 {
6799 std::vector<std::string> uniqueError;
6800 char buf[512];
6801 for(size_t q = 1; q < Cheat::Last; ++q)
6802 {
6803 if(cheatkeys[q][1] && !cheatkeys[q][0])
6804 {
6805 cheatkeys[q][0] = cheatkeys[q][1];
6806 cheatkeys[q][1] = 0;
6807 }
6808 }
6809 for(size_t q = 1; q < Cheat::Last; ++q)
6810 {
6811 if(!bindable_cheat((Cheat)q)) continue;
6812 for(size_t p = q+1; p < Cheat::Last; ++p)
6813 {
6814 if(!bindable_cheat((Cheat)p)) continue;
6815 for(size_t q2 = 0; q2 <= 1; ++q2)
6816 for(size_t p2 = 0; p2 <= 1; ++p2)
6817 {
6818 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6819 {
6820 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6821 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6822 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6823 get_keystr(cheatkeys[q][q2])));
6824 }
6825 }
6826 }
6827 }
6828 if(uniqueError.size() == 0)
6829 {
6830 done = true;
6831 save_cheatkeys();
6832 }
6833 else
6834 {
6835 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6836 box_out("Cannot have duplicate keybinds!"); box_eol();
6837 for(std::vector<std::string>::iterator it = uniqueError.begin();
6838 it != uniqueError.end(); ++it)
6839 {
6840 box_out((*it).c_str()); box_eol();
6841 }
6842 box_end(true);
6843 }
6844 }
6845 else // Cancel
6846 {
6847 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6848 done=true;
6849 }
6850 rest(1);
6851 }
6852
6853 return D_O_K;
6854 }
6855
6856 int32_t onSound()
6857 {
6858 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6859 {
6860 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6861 }
6862 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6863 {
6864 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6865 }
6866 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6867 {
6868 emusic_volume = (int32_t)FFCore.usr_music_volume;
6869 }
6870 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
6871 {
6872 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6873 }
6874 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6875 {
6876 pan_style = (int32_t)FFCore.usr_panstyle;
6877 }
6878
6879 int32_t m = midi_volume;
6880 int32_t d = digi_volume;
6881 int32_t e = emusic_volume;
6882 int32_t b = zcmusic_bufsz;
6883 int32_t s = sfx_volume;
6884 int32_t p = pan_style;
6885 pan_style = vbound(pan_style,0,3);
6886
6887 sound_dlg[0].dp2=get_zc_font(font_lfont);
6888
6889 large_dialog(sound_dlg);
6890
6891 midi_dp[1] = sound_dlg[6].x;
6892 midi_dp[2] = sound_dlg[6].y;
6893 digi_dp[1] = sound_dlg[7].x;
6894 digi_dp[2] = sound_dlg[7].y;
6895 emus_dp[1] = sound_dlg[8].x;
6896 emus_dp[2] = sound_dlg[8].y;
6897 buf_dp[1] = sound_dlg[9].x;
6898 buf_dp[2] = sound_dlg[9].y;
6899 sfx_dp[1] = sound_dlg[10].x;
6900 sfx_dp[2] = sound_dlg[10].y;
6901 pan_dp[1] = sound_dlg[11].x;
6902 pan_dp[2] = sound_dlg[11].y;
6903 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6904 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6905 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6906 sound_dlg[18].d2 = zcmusic_bufsz;
6907 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6908 sound_dlg[20].d2 = pan_style;
6909
6910 int32_t ret = zc_popup_dialog(sound_dlg,1);
6911
6912 if(ret==2)
6913 {
6914 master_volume(digi_volume,midi_volume);
6915
6916 for(int32_t i=0; i<WAV_COUNT; ++i)
6917 {
6918 //allegro assertion fails when passing in -1 as voice -DD
6919 if(sfx_voice[i] > 0)
6920 voice_set_volume(sfx_voice[i], sfx_volume);
6921 }
6922 zc_set_config(sfx_sect,"digi",digi_volume);
6923 zc_set_config(sfx_sect,"midi",midi_volume);
6924 zc_set_config(sfx_sect,"sfx",sfx_volume);
6925 zc_set_config(sfx_sect,"emusic",emusic_volume);
6926 zc_set_config(sfx_sect,"pan",pan_style);
6927 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6928 }
6929 else
6930 {
6931 midi_volume = m;
6932 digi_volume = d;
6933 emusic_volume = e;
6934 zcmusic_bufsz = b;
6935 sfx_volume = s;
6936 pan_style = p;
6937 }
6938
6939 return D_O_K;
6940 }
6941
6942 int32_t queding(char const* s1, char const* s2, char const* s3)
6943 {
6944 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6945 }
6946
6947 int32_t onQuit()
6948 {
6949 if(Playing)
6950 {
6951 int32_t ret=0;
6952
6953 if(get_bit(quest_rules, qr_NOCONTINUE))
6954 {
6955 if(standalone_mode)
6956 {
6957 ret=queding("End current game?",
6958 "The continue screen is disabled; the game",
6959 "will be reloaded from the last save.");
6960 }
6961 else
6962 {
6963 ret=queding("End current game?",
6964 "The continue screen is disabled. You will",
6965 "be returned to the file select screen.");
6966 }
6967 }
6968 else
6969 ret=queding("End current game?",NULL,NULL);
6970
6971 if(ret==1)
6972 {
6973 disableClickToFreeze=false;
6974 Quit=qQUIT;
6975
6976 // Trying to evade a door repair charge?
6977 if(repaircharge)
6978 {
6979 game->change_drupy(-repaircharge);
6980 repaircharge=0;
6981 }
6982
6983 return D_CLOSE;
6984 }
6985 }
6986
6987 return D_O_K;
6988 }
6989
6990 int32_t onTryQuitMenu()
6991 {
6992 return onTryQuit(true);
6993 }
6994
6995 int32_t onTryQuit(bool inMenu)
6996 {
6997 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
6998 {
6999 if(active_cutscene.can_f6())
7000 {
7001 if(get_bit(quest_rules,qr_OLD_F6))
7002 {
7003 if(inMenu) onQuit();
7004 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7005 }
7006 else
7007 {
7008 disableClickToFreeze=false;
7009 GameFlags |= GAMEFLAG_TRYQUIT;
7010 }
7011 return D_CLOSE;
7012 }
7013 else active_cutscene.error();
7014 }
7015
7016 return D_O_K;
7017 }
7018
7019 int32_t onReset()
7020 {
7021 if(queding(" Reset system? ",NULL,NULL)==1)
7022 {
7023 disableClickToFreeze=false;
7024 Quit=qRESET;
7025 replay_quit();
7026 return D_CLOSE;
7027 }
7028
7029 return D_O_K;
7030 }
7031
7032 int32_t onExit()
7033 {
7034 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7035 {
7036 Quit=qEXIT;
7037 return D_CLOSE;
7038 }
7039
7040 return D_O_K;
7041 }
7042
7043 int32_t onTitle_NES()
7044 {
7045 title_version=0;
7046 zc_set_config(cfg_sect,"title",title_version);
7047 return D_O_K;
7048 }
7049 int32_t onTitle_DX()
7050 {
7051 title_version=1;
7052 zc_set_config(cfg_sect,"title",title_version);
7053 return D_O_K;
7054 }
7055 int32_t onTitle_25()
7056 {
7057 title_version=2;
7058 zc_set_config(cfg_sect,"title",title_version);
7059 return D_O_K;
7060 }
7061
7062 int32_t onDebug()
7063 {
7064 if(debug_enabled)
7065 set_debug(!get_debug());
7066 return D_O_K;
7067 }
7068
7069 int32_t onHeartBeep()
7070 {
7071 heart_beep=!heart_beep;
7072 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7073 return D_O_K;
7074 }
7075
7076 int32_t onSaveIndicator()
7077 {
7078 use_save_indicator = use_save_indicator ? 0 : 1;
7079 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7080 return D_O_K;
7081 }
7082
7083 int32_t onEpilepsy()
7084 {
7085 if(jwin_alert3(
7086 "Epilepsy Flash Reduction",
7087 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7088 "Disabling this will restore standard flash and wavy behaviour.",
7089 "Proceed?",
7090 "&Yes",
7091 "&No",
7092 NULL,
7093 'y',
7094 'n',
7095 0,
7096 get_zc_font(font_lfont)) == 1)
7097 {
7098 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7099 zc_set_config("zeldadx","checked_epilepsy",1);
7100 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7101 }
7102 return D_O_K;
7103 }
7104
7105 int32_t onTriforce()
7106 {
7107 for(int32_t i=0; i<MAXINITTABS; ++i)
7108 {
7109 init_tabs[i].flags&=~D_SELECTED;
7110 }
7111
7112 init_tabs[3].flags=D_SELECTED;
7113 return onCheatConsole();
7114 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7115 for(int32_t i=1; i<=8; i++)
7116 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7117
7118 if(zc_popup_dialog (triforce_dlg,-1)==9)
7119 {
7120 for(int32_t i=1; i<=8; i++)
7121 {
7122 game->lvlitems[i] &= ~liTRIFORCE;
7123 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7124 }
7125 }
7126 return D_O_K;*/
7127 }
7128
7129 bool rc = false;
7130 /*
7131 int32_t onEquipment()
7132 {
7133 for (int32_t i=0; i<MAXINITTABS; ++i)
7134 {
7135 init_tabs[i].flags&=~D_SELECTED;
7136 }
7137 init_tabs[0].flags=D_SELECTED;
7138 return onCheatConsole();
7139 }
7140 */
7141
7142 int32_t onItems()
7143 {
7144 for(int32_t i=0; i<MAXINITTABS; ++i)
7145 {
7146 init_tabs[i].flags&=~D_SELECTED;
7147 }
7148
7149 init_tabs[1].flags=D_SELECTED;
7150 return onCheatConsole();
7151 }
7152
7153 static DIALOG getnum_dlg[] =
7154 {
7155 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7156 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7157 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7158 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7159 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7160 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7161 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7162 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7163 };
7164
7165 int32_t getnumber(const char *prompt,int32_t initialval)
7166 {
7167 char buf[20];
7168 sprintf(buf,"%d",initialval);
7169 getnum_dlg[0].dp=(void *)prompt;
7170 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7171 getnum_dlg[2].dp=buf;
7172
7173 large_dialog(getnum_dlg);
7174
7175 if(zc_popup_dialog(getnum_dlg,2)==3)
7176 return atoi(buf);
7177
7178 return initialval;
7179 }
7180
7181 int32_t onLife()
7182 {
7183 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7184 cheats_enqueue(Cheat::Life, value);
7185 return D_O_K;
7186 }
7187
7188 int32_t onHeartC()
7189 {
7190 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7191 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7192 cheats_enqueue(Cheat::MaxLife, max_life);
7193 cheats_enqueue(Cheat::Life, life);
7194 return D_O_K;
7195 }
7196
7197 int32_t onMagicC()
7198 {
7199 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7200 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7201 cheats_enqueue(Cheat::MaxMagic, max_magic);
7202 cheats_enqueue(Cheat::Magic, magic);
7203 return D_O_K;
7204 }
7205
7206 int32_t onRupies()
7207 {
7208 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7209 cheats_enqueue(Cheat::Rupies, value);
7210 return D_O_K;
7211 }
7212
7213 int32_t onMaxBombs()
7214 {
7215 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7216 cheats_enqueue(Cheat::MaxBombs, value);
7217 cheats_enqueue(Cheat::Bombs, value);
7218 return D_O_K;
7219 }
7220
7221 int32_t onRefillLife()
7222 {
7223 cheats_enqueue(Cheat::Life, game->get_maxlife());
7224 return D_O_K;
7225 }
7226 int32_t onRefillMagic()
7227 {
7228 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7229 return D_O_K;
7230 }
7231 int32_t onClock()
7232 {
7233 cheats_enqueue(Cheat::Clock);
7234 return D_O_K;
7235 }
7236
7237 int32_t onQstPath()
7238 {
7239 char path[2048];
7240
7241 chop_path(qstdir);
7242 strcpy(path,qstdir);
7243
7244 go();
7245
7246 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7247 {
7248 chop_path(path);
7249 fix_filename_case(path);
7250 fix_filename_slashes(path);
7251 strcpy(qstdir,path);
7252 strcpy(qstpath,qstdir);
7253 }
7254
7255 comeback();
7256 return D_O_K;
7257 }
7258
7259 #include "dialog/cheat_dialog.h"
7260 int32_t onCheat()
7261 {
7262 call_setcheat_dialog();
7263 game->set_cheat(maxcheat);
7264 if(cheat) game->did_cheat(true);
7265 return D_O_K;
7266 }
7267
7268 int32_t onCheatRupies()
7269 {
7270 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7271 return D_O_K;
7272 }
7273
7274 int32_t onCheatArrows()
7275 {
7276 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7277 return D_O_K;
7278 }
7279
7280 int32_t onCheatBombs()
7281 {
7282 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7283 return D_O_K;
7284 }
7285
7286 // *** screen saver
7287
7288 8114047 int32_t after_time()
7289 {
7290
1/2
✓ Branch 0 taken 8114047 times.
✗ Branch 1 not taken.
8114047 if(ss_enable == 0)
7291 return INT_MAX;
7292
7293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8114047 times.
8114047 if(ss_after <= 0)
7294 return 5 * 60;
7295
7296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8114047 times.
8114047 if(ss_after <= 3)
7297 return ss_after * 15 * 60;
7298
7299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8114047 times.
8114047 if(ss_after <= 13)
7300 return (ss_after - 3) * 60 * 60;
7301
7302 8114047 return MAX_IDLE + 1;
7303 8114047 }
7304
7305 static const char *after_str[15] =
7306 {
7307 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7308 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7309 "Never"
7310 };
7311
7312 const char *after_list(int32_t index, int32_t *list_size)
7313 {
7314 if(index < 0)
7315 {
7316 *list_size = 15;
7317 return NULL;
7318 }
7319
7320 return after_str[index];
7321 }
7322
7323 36 static ListData after__list(after_list, &font);
7324
7325 static DIALOG scrsaver_dlg[] =
7326 {
7327 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7328 36 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7329 36 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7330 36 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7331 36 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7332 36 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7333 36 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7334 36 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7335 36 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7336 36 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7337 36 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7338 36 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7339 36 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7340 36 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7341 };
7342
7343 int32_t onScreenSaver()
7344 {
7345 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7346 int32_t oldcfgs[3];
7347 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7348 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7349 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7350
7351 large_dialog(scrsaver_dlg);
7352
7353 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7354
7355 if(ret == 8 || ret == 9)
7356 {
7357 ss_after = scrsaver_dlg[5].d1;
7358 ss_speed = scrsaver_dlg[6].d2;
7359 ss_density = scrsaver_dlg[7].d2;
7360 if(oldcfgs[0] != ss_after)
7361 zc_set_config(cfg_sect,"ss_after",ss_after);
7362 if(oldcfgs[1] != ss_speed)
7363 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7364 if(oldcfgs[2] != ss_density)
7365 zc_set_config(cfg_sect,"ss_density",ss_density);
7366 }
7367
7368 if(ret == 9)
7369 // preview Screen Saver
7370 {
7371 clear_keybuf();
7372 Matrix(ss_speed, ss_density, 30);
7373 system_pal();
7374 sys_mouse();
7375 }
7376
7377 return D_O_K;
7378 }
7379
7380 /***** Menus *****/
7381
7382 static MENU game_menu[] =
7383 {
7384 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7385 { (char *)"", NULL, NULL, 0, NULL },
7386 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7387 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7388 { (char *)"", NULL, NULL, 0, NULL },
7389 #ifdef __EMSCRIPTEN__
7390 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7391 #elif defined(ALLEGRO_MACOSX)
7392 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7393 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7394 #else
7395 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7396 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7397 #endif
7398 { NULL, NULL, NULL, 0, NULL }
7399 };
7400
7401 static MENU title_menu[] =
7402 {
7403 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7404 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7405 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7406 { NULL, NULL, NULL, 0, NULL }
7407 };
7408
7409 static MENU snapshot_format_menu[] =
7410 {
7411 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7412 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7413 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7414 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7415 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7416 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7417 { NULL, NULL, NULL, 0, NULL }
7418 };
7419
7420 static MENU controls_menu[] =
7421 {
7422 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7423 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7424 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7425 { NULL, NULL, NULL, 0, NULL }
7426 };
7427
7428 static MENU name_entry_mode_menu[] =
7429 {
7430 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7431 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7432 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7433 { NULL, NULL, NULL, 0, NULL }
7434 };
7435
7436 static void set_controls_menu_active()
7437 {
7438
7439 }
7440
7441 static MENU window_menu[] =
7442 {
7443 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7444 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7445 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7446 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7447 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7448 { NULL, NULL, NULL, 0, NULL }
7449 };
7450 static MENU options_menu[] =
7451 {
7452 { "&Title Screen", NULL, title_menu, 0, NULL },
7453 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7454 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7455 { "&Window Settings", NULL, window_menu, 0, NULL },
7456 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7457 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7458 { NULL, NULL, NULL, 0, NULL }
7459 };
7460 static MENU settings_menu[] =
7461 {
7462 { "&Sound...", onSound, NULL, 0, NULL },
7463 { "C&ontrols", NULL, controls_menu, 0, NULL },
7464 { "", NULL, NULL, 0, NULL },
7465 { "Options", NULL, options_menu, 0, NULL },
7466 { "", NULL, NULL, 0, NULL },
7467 //
7468 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7469 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7470 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7471 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7472 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7473 //
7474 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7475 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7476 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7477 { "", NULL, NULL, 0, NULL },
7478 { "Debu&g", onDebug, NULL, 0, NULL },
7479 //
7480 { NULL, NULL, NULL, 0, NULL }
7481 };
7482
7483
7484 static MENU misc_menu[] =
7485 {
7486 { (char *)"&About...", onAbout, NULL, 0, NULL },
7487 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7488 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7489 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7490 { (char *)"", NULL, NULL, 0, NULL },
7491 //5
7492 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7493 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7494 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7495 { (char *)"", NULL, NULL, 0, NULL },
7496 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7497 //10
7498 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7499 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7500 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7501 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7502 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7503 //15
7504 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7505 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7506 { NULL, NULL, NULL, 0, NULL }
7507 };
7508
7509 static MENU refill_menu[] =
7510 {
7511 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7512 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7513 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7514 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7515 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7516 { NULL, NULL, NULL, 0, NULL }
7517 };
7518
7519 static MENU show_menu[] =
7520 {
7521 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7522 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7523 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7524 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7525 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7526 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7527 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7528 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7529 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7530 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7531 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7532 { (char *)"", NULL, NULL, 0, NULL },
7533 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7534 { (char *)"", NULL, NULL, 0, NULL },
7535 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7536 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7537 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7538 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7539 { NULL, NULL, NULL, 0, NULL }
7540 };
7541
7542 static MENU cheat_menu[] =
7543 {
7544 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7545 { (char *)"", NULL, NULL, 0, NULL },
7546 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7547 { (char *)"", NULL, NULL, 0, NULL },
7548 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7549 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7550 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7551 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7552 { (char *)"", NULL, NULL, 0, NULL },
7553 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7554 { (char *)"", NULL, NULL, 0, NULL },
7555 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7556 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7557 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7558 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7559 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7560 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7561 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7562 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7563 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7564 { NULL, NULL, NULL, 0, NULL }
7565 };
7566
7567 #if DEVLEVEL > 0
7568 int32_t devLogging();
7569 int32_t devDebug();
7570 int32_t devTimestmp();
7571 #if DEVLEVEL > 1
7572 int32_t setCheat();
7573 #endif //DEVLEVEL > 1
7574 enum
7575 {
7576 dv_log,
7577 // dv_dbg,
7578 dv_tmpstmp,
7579 #if DEVLEVEL > 1
7580 dv_nil,
7581 dv_setcheat,
7582 #endif //DEVLEVEL > 1
7583 dv_max
7584 };
7585 static MENU dev_menu[] =
7586 {
7587 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7588 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7589 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7590 #if DEVLEVEL > 1
7591 { (char *)"", NULL, NULL, 0, NULL },
7592 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7593 #endif //DEVLEVEL > 1
7594 { NULL, NULL, NULL, 0, NULL }
7595 };
7596 int32_t devLogging()
7597 {
7598 dev_logging = !dev_logging;
7599 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7600 return D_O_K;
7601 }
7602 // int32_t devDebug()
7603 // {
7604 // dev_debug = !dev_debug;
7605 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7606 // return D_O_K;
7607 // }
7608 int32_t devTimestmp()
7609 {
7610 dev_timestmp = !dev_timestmp;
7611 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7612 return D_O_K;
7613 }
7614 #if DEVLEVEL > 1
7615 int32_t setCheat()
7616 {
7617 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7618 return D_O_K;
7619 }
7620 #endif //DEVLEVEL > 1
7621 #endif //DEVLEVEL > 0
7622
7623 MENU the_player_menu[] =
7624 {
7625 { (char *)"&Game", NULL, game_menu, 0, NULL },
7626 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7627 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7628 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7629 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7630 #if DEVLEVEL > 0
7631 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7632 #endif
7633 { NULL, NULL, NULL, 0, NULL }
7634 };
7635 int32_t onMIDIPatch()
7636 {
7637 if(jwin_alert3(
7638 "Toggle Windows MIDI Fix",
7639 "This action will change whether ZC Player auto-restarts a MIDI at its",
7640 "last index if you move ZC Player out of focus, then back into focus.",
7641 "Proceed?",
7642 "&Yes",
7643 "&No",
7644 NULL,
7645 'y',
7646 'n',
7647 0,
7648 get_zc_font(font_lfont)) == 1)
7649 {
7650 midi_patch_fix = midi_patch_fix ? 0 : 1;
7651 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7652 }
7653 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7654 return D_O_K;
7655 }
7656
7657 int32_t onKeyboardEntry()
7658 {
7659 NameEntryMode=0;
7660 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7661 return D_O_K;
7662 }
7663
7664 int32_t onLetterGridEntry()
7665 {
7666 NameEntryMode=1;
7667 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7668 return D_O_K;
7669 }
7670
7671 int32_t onExtLetterGridEntry()
7672 {
7673 NameEntryMode=2;
7674 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7675 return D_O_K;
7676 }
7677
7678 static BITMAP* oldscreen;
7679 int32_t onFullscreenMenu()
7680 {
7681 // super hacks
7682 screen = oldscreen;
7683 if (onFullscreen() == D_REDRAW)
7684 {
7685 oldscreen = screen;
7686 }
7687 screen = menu_bmp;
7688 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7689 return D_O_K;
7690 }
7691
7692 36 void fix_menu()
7693 {
7694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!debug_enabled)
7695 36 settings_menu[13].text = NULL;
7696 36 }
7697
7698 static DIALOG system_dlg[] =
7699 {
7700 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7701 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7702 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7703 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7704 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7705 #ifndef ALLEGRO_MACOSX
7706 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7707 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7708 #else
7709 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7710 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7711 #endif
7712 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7713 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7714 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7715 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7716 };
7717
7718 void reset_snapshot_format_menu()
7719 {
7720 for(int32_t i=0; i<ssfmtMAX; ++i)
7721 {
7722 snapshot_format_menu[i].flags=0;
7723 }
7724 }
7725
7726 int32_t onSetSnapshotFormat()
7727 {
7728 switch(active_menu->text[1])
7729 {
7730 case 'B': //"&BMP"
7731 SnapshotFormat=0;
7732 break;
7733
7734 case 'G': //"&GIF"
7735 SnapshotFormat=1;
7736 break;
7737
7738 case 'J': //"&JPG"
7739 SnapshotFormat=2;
7740 break;
7741
7742 case 'P': //"&PNG"
7743 SnapshotFormat=3;
7744 break;
7745
7746 case 'C': //"PC&X"
7747 SnapshotFormat=4;
7748 break;
7749
7750 case 'T': //"&TGA"
7751 SnapshotFormat=5;
7752 break;
7753
7754 case 'L': //"&LBM"
7755 SnapshotFormat=6;
7756 break;
7757 }
7758 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7759
7760 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7761 return D_O_K;
7762 }
7763
7764
7765 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7766 {
7767 PALETTE tmp;
7768
7769 for(int32_t i=0; i<256; i++)
7770 {
7771 tmp[i].r=r;
7772 tmp[i].g=g;
7773 tmp[i].b=b;
7774 }
7775
7776 fade_interpolate(src,tmp,dest,pos,from,to);
7777 }
7778
7779 49 void system_pal(bool force)
7780 {
7781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49 if(is_sys_pal && !force) return;
7782 49 is_sys_pal = true;
7783 49 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7784 49 hw_palette = &syspal;
7785 49 update_hw_pal = true;
7786 49 }
7787
7788 static uint32_t entered_sys_pal = 0;
7789 49 void enter_sys_pal()
7790 {
7791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(is_sys_pal)
7792 {
7793 if(entered_sys_pal)
7794 ++entered_sys_pal;
7795 return;
7796 }
7797 49 sys_mouse();
7798 49 system_pal(true);
7799 49 ++entered_sys_pal;
7800 49 }
7801 49 void exit_sys_pal()
7802 {
7803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(entered_sys_pal)
7804 {
7805
1/2
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
49 if(!--entered_sys_pal)
7806 {
7807 49 game_pal();
7808 49 game_mouse();
7809 49 }
7810 49 }
7811 49 }
7812
7813 void switch_out_callback()
7814 {
7815 if (pause_in_background)
7816 {
7817 callback_switchin = 3;
7818 return;
7819 }
7820
7821 #ifdef _WIN32
7822 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
7823 return;
7824
7825
7826 paused_midi_pos = midi_pos;
7827 zc_stop_midi();
7828 midi_paused=true;
7829 midi_suspended = midissuspHALTED;
7830 #endif
7831 }
7832
7833 void switch_in_callback()
7834 {
7835 if(pause_in_background)
7836 {
7837 return;
7838 }
7839
7840 #ifdef _WIN32
7841 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
7842 return;
7843
7844 else
7845 {
7846 callback_switchin = 1;
7847 midi_suspended = midissuspRESUME;
7848 }
7849 #endif
7850 }
7851
7852 346 void game_pal()
7853 {
7854 346 is_sys_pal = false;
7855 346 entered_sys_pal = 0;
7856 346 hw_palette = &RAMpal;
7857 346 update_hw_pal = true;
7858 346 }
7859
7860 static char bar_str[] = "";
7861
7862 13 void music_pause()
7863 {
7864 //al_pause_duh(tmplayer);
7865 13 zcmusic_pause(zcmusic, ZCM_PAUSE);
7866 13 zc_midi_pause();
7867 13 midi_paused=true;
7868 13 }
7869
7870 void music_resume()
7871 {
7872 //al_resume_duh(tmplayer);
7873 zcmusic_pause(zcmusic, ZCM_RESUME);
7874 zc_midi_resume();
7875 midi_paused=false;
7876 }
7877
7878 6579 void music_stop()
7879 {
7880 //al_stop_duh(tmplayer);
7881 //unload_duh(tmusic);
7882 //tmusic=NULL;
7883 //tmplayer=NULL;
7884 6579 zcmusic_stop(zcmusic);
7885 6579 zcmusic_unload_file(zcmusic);
7886 6579 zc_stop_midi();
7887 6579 midi_paused=false;
7888 6579 currmidi=-1;
7889 6579 }
7890
7891 void System()
7892 {
7893 mouse_down=gui_mouse_b();
7894 music_pause();
7895 pause_all_sfx();
7896 MenuOpen = true;
7897 enter_sys_pal();
7898 // FONT *oldfont=font;
7899 // font=tfont;
7900
7901 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7902 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7903
7904 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7905 #if DEVLEVEL > 1
7906 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7907 #endif
7908 game_menu[3].flags =
7909 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7910 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7911 clear_keybuf();
7912
7913 DIALOG_PLAYER *p;
7914
7915 clear_bitmap(menu_bmp);
7916 oldscreen = screen;
7917 screen = menu_bmp;
7918
7919 p = init_dialog(system_dlg,-1);
7920
7921 // drop the menu on startup if menu button pressed
7922 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7923 simulate_keypress(KEY_G << 8);
7924
7925 do
7926 {
7927 if(close_button_quit)
7928 {
7929 close_button_quit = false;
7930 f_Quit(qEXIT);
7931 if(Quit) break;
7932 }
7933 rest(17);
7934
7935 if(mouse_down && !gui_mouse_b())
7936 mouse_down=0;
7937
7938 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
7939 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
7940 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
7941
7942 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7943 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7944 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7945 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7946 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7947 settings_menu[10].flags = NESquit?D_SELECTED:0;
7948 settings_menu[11].flags = volkeys?D_SELECTED:0;
7949
7950 window_menu[0].flags = DragAspect?D_SELECTED:0;
7951 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7952 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7953 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7954 window_menu[4].flags = stretchGame?D_SELECTED:0;
7955
7956 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7957 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
7958
7959 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7960 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7961 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7962
7963 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7964 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7965 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7966
7967 bool nocheat = (replay_is_replaying() || !Playing
7968 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7969 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7970 cheat_menu[0].flags = 0;
7971 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
7972 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7973 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7974 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7975 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7976 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7977 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7978 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7979 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7980
7981 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7982 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7983 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7984 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7985 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7986 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7987 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7988 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7989 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7990 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7991 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7992 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7993 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7994 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7995 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7996
7997 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7998 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7999
8000 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8001 (char *)"Disable recording new saves" :
8002 (char *)"Enable recording new saves";
8003 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8004 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8005 (char *)"Stop recording" :
8006 (char *)"Stop replaying";
8007 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8008 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8009 (char *)"Disable snapshot all frames" :
8010 (char *)"Enable snapshot all frames";
8011
8012 reset_snapshot_format_menu();
8013 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8014
8015 if(debug_enabled)
8016 {
8017 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8018 }
8019
8020 if(gui_mouse_b() && !mouse_down)
8021 break;
8022
8023 // press menu to drop the menu
8024 if(rMbtn())
8025 simulate_keypress(KEY_G << 8);
8026
8027 if(input_idle(true) > after_time())
8028 // run Screeen Saver
8029 {
8030 // Screen saver enabled for now.
8031 clear_keybuf();
8032 Matrix(ss_speed, ss_density, 0);
8033 system_pal();
8034 sys_mouse();
8035 broadcast_dialog_message(MSG_DRAW, 0);
8036 }
8037
8038 update_hw_screen();
8039 }
8040 while(update_dialog(p));
8041
8042 screen = oldscreen;
8043
8044 // font=oldfont;
8045 mouse_down=gui_mouse_b();
8046 shutdown_dialog(p);
8047 MenuOpen = false;
8048 if(Quit)
8049 {
8050 kill_sfx();
8051 music_stop();
8052 update_hw_screen();
8053 }
8054 else
8055 {
8056 music_resume();
8057 resume_all_sfx();
8058
8059 if(rc)
8060 ringcolor(false);
8061 }
8062 exit_sys_pal();
8063
8064 eat_buttons();
8065
8066 rc=false;
8067 clear_keybuf();
8068 // text_mode(0);
8069 }
8070
8071 36 void fix_dialogs()
8072 {
8073 36 jwin_center_dialog(about_dlg);
8074 36 jwin_center_dialog(gamepad_dlg);
8075 36 jwin_center_dialog(credits_dlg);
8076 36 jwin_center_dialog(gamemode_dlg);
8077 36 jwin_center_dialog(getnum_dlg);
8078 36 jwin_center_dialog(goto_dlg);
8079 36 jwin_center_dialog(keyboard_control_dlg);
8080 36 jwin_center_dialog(midi_dlg);
8081 36 jwin_center_dialog(quest_dlg);
8082 36 jwin_center_dialog(scrsaver_dlg);
8083 36 jwin_center_dialog(sound_dlg);
8084 36 jwin_center_dialog(triforce_dlg);
8085
8086 // digi_dp[1] += scrx;
8087 // digi_dp[2] += scry;
8088 // midi_dp[1] += scrx;
8089 // midi_dp[2] += scry;
8090 // pan_dp[1] += scrx;
8091 // pan_dp[2] += scry;
8092 // emus_dp[1] += scrx;
8093 // emus_dp[2] += scry;
8094 // buf_dp[1] += scrx;
8095 // buf_dp[2] += scry;
8096 // sfx_dp[1] += scrx;
8097 // sfx_dp[2] += scry;
8098 36 }
8099
8100 /*****************************/
8101 /**** Custom Sound System ****/
8102 /*****************************/
8103
8104 2896 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8105 {
8106
3/4
✓ Branch 0 taken 2638 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 2896 times.
✗ Branch 3 not taken.
2896 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8107 }
8108
8109 // Run an NSF, or a MIDI if the NSF is missing somehow.
8110 106 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8111 {
8112 106 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8113
8114 // Found it
8115
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 38 times.
106 if(newzcmusic!=NULL)
8116 {
8117 68 zcmusic_stop(zcmusic);
8118 68 zcmusic_unload_file(zcmusic);
8119 68 zc_stop_midi();
8120
8121 68 zcmusic=newzcmusic;
8122 68 zcmusic_play(zcmusic, emusic_volume);
8123
8124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(track>0)
8125 68 zcmusic_change_track(zcmusic,track);
8126
8127 68 return true;
8128 }
8129
8130 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8131
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 else if(midi>-1000)
8132 jukebox(midi);
8133
8134 38 return false;
8135 106 }
8136
8137 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8138 {
8139 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8140 // Found it
8141 if(newzcmusic!=NULL)
8142 {
8143 zcmusic_stop(zcmusic);
8144 zcmusic_unload_file(zcmusic);
8145 zc_stop_midi();
8146
8147 zcmusic=newzcmusic;
8148 zcmusic_play(zcmusic, emusic_volume);
8149
8150 if(track>0)
8151 zcmusic_change_track(zcmusic,track);
8152
8153 return true;
8154 }
8155
8156 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8157 else if(midi>-1000)
8158 jukebox(midi);
8159
8160 return false;
8161 }
8162
8163 int32_t get_zcmusicpos()
8164 {
8165 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8166 return debugtracething;
8167 return 0;
8168 }
8169
8170 void set_zcmusicpos(int32_t position)
8171 {
8172 zcmusic_set_curpos(zcmusic, position);
8173 }
8174
8175 void set_zcmusicspeed(int32_t speed)
8176 {
8177 int32_t newspeed = vbound(speed, 0, 10000);
8178 zcmusic_set_speed(zcmusic, newspeed);
8179 }
8180
8181 1430 void jukebox(int32_t index,int32_t loop)
8182 {
8183 1430 music_stop();
8184
8185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(index<0) index=MAXMIDIS-1;
8186
8187
1/2
✓ Branch 0 taken 1430 times.
✗ Branch 1 not taken.
1430 if(index>=MAXMIDIS) index=0;
8188
8189 1430 music_stop();
8190
8191 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8192 // stuck notes when a song stops. This fixes it.
8193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(strcmp(midi_driver->name, "DIGMID")==0)
8194 zc_set_volume(0, 0);
8195
8196 1430 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8197 1430 zc_play_midi((MIDI*)tunes[index].data,loop);
8198
8199
2/2
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 402 times.
1430 if(tunes[index].start>0)
8200 402 zc_midi_seek(tunes[index].start);
8201
8202 1430 midi_loop_start = tunes[index].loop_start;
8203 1430 midi_loop_end = tunes[index].loop_end;
8204
8205 1430 currmidi=index;
8206 1430 master_volume(digi_volume,midi_volume);
8207 1430 midi_paused=false;
8208 1430 }
8209
8210 11407 void jukebox(int32_t index)
8211 {
8212
1/2
✓ Branch 0 taken 11407 times.
✗ Branch 1 not taken.
11407 if(index<0) index=MAXMIDIS-1;
8213
8214
1/2
✓ Branch 0 taken 11407 times.
✗ Branch 1 not taken.
11407 if(index>=MAXMIDIS) index=0;
8215
8216 // do nothing if it's already playing
8217
3/4
✓ Branch 0 taken 9977 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 9977 times.
✗ Branch 3 not taken.
11407 if(index==currmidi && midi_pos>=0)
8218 {
8219 9977 midi_paused=false;
8220 9977 return;
8221 }
8222
8223 1430 jukebox(index,tunes[index].loop);
8224 11407 }
8225
8226 12732 void play_DmapMusic()
8227 {
8228 static char tfile[2048];
8229 static int32_t ttrack=0;
8230 12732 bool domidi=false;
8231
8232
2/2
✓ Branch 0 taken 1455 times.
✓ Branch 1 taken 11277 times.
12732 if(DMaps[currdmap].tmusic[0]!=0)
8233 {
8234
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1070 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1840 if(zcmusic==NULL ||
8235
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8236
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8237 {
8238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1070 times.
1070 if(zcmusic != NULL)
8239 {
8240 zcmusic_stop(zcmusic);
8241 zcmusic_unload_file(zcmusic);
8242 zcmusic = NULL;
8243 }
8244
8245 1070 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8246
8247
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 983 times.
1070 if(zcmusic!=NULL)
8248 {
8249 87 zc_stop_midi();
8250 87 strcpy(tfile,DMaps[currdmap].tmusic);
8251 87 zcmusic_play(zcmusic, emusic_volume);
8252 87 int32_t temptracks=0;
8253 87 temptracks=zcmusic_get_tracks(zcmusic);
8254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 temptracks=(temptracks<2)?1:temptracks;
8255 87 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8256 87 zcmusic_change_track(zcmusic,ttrack);
8257 87 }
8258 else
8259 {
8260 983 tfile[0] = 0;
8261 983 domidi=true;
8262 }
8263 1070 }
8264 1455 }
8265 else
8266 {
8267 11277 domidi=true;
8268 }
8269
8270
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 12260 times.
12732 if(domidi)
8271 {
8272 12260 int32_t m=DMaps[currdmap].midi;
8273
8274
3/4
✓ Branch 0 taken 11868 times.
✓ Branch 1 taken 373 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
12260 switch(m)
8275 {
8276 case 1:
8277 373 jukebox(ZC_MIDI_OVERWORLD);
8278 373 break;
8279
8280 case 2:
8281 19 jukebox(ZC_MIDI_DUNGEON);
8282 19 break;
8283
8284 case 3:
8285 jukebox(ZC_MIDI_LEVEL9);
8286 break;
8287
8288 default:
8289
3/4
✓ Branch 0 taken 10843 times.
✓ Branch 1 taken 1025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10843 times.
11868 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8290 10843 jukebox(m+MIDIOFFSET_DMAP);
8291 else
8292 1025 music_stop();
8293 11868 }
8294 12260 }
8295 12732 }
8296
8297 12770 void playLevelMusic()
8298 {
8299 12770 int32_t m=tmpscr->screen_midi;
8300
8301
3/6
✓ Branch 0 taken 12716 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
12770 switch(m)
8302 {
8303 case -2:
8304 13 music_stop();
8305 13 break;
8306
8307 case -1:
8308 12716 play_DmapMusic();
8309 12716 break;
8310
8311 case 1:
8312 jukebox(ZC_MIDI_OVERWORLD);
8313 break;
8314
8315 case 2:
8316 jukebox(ZC_MIDI_DUNGEON);
8317 break;
8318
8319 case 3:
8320 jukebox(ZC_MIDI_LEVEL9);
8321 break;
8322
8323 default:
8324
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8325 41 jukebox(m+MIDIOFFSET_MAPSCR);
8326 else
8327 music_stop();
8328 41 }
8329 12770 }
8330
8331 1466 void master_volume(int32_t dv,int32_t mv)
8332 {
8333
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1466 times.
✓ Branch 2 taken 1466 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1466 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1466 times.
✗ Branch 7 not taken.
1466 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8334
8335
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1466 times.
✓ Branch 2 taken 1466 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1466 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1466 times.
✗ Branch 7 not taken.
1466 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8336
8337
6/6
✓ Branch 0 taken 1427 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 1464 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1425 times.
✓ Branch 5 taken 39 times.
1466 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8338 1466 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8339 1466 }
8340
8341 /*****************/
8342 /***** SFX *****/
8343 /*****************/
8344
8345 // array of voices, one for each sfx sample in the data file
8346 // 0+ = voice #
8347 // -1 = voice not allocated
8348 36 void Z_init_sound()
8349 {
8350
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i=0; i<WAV_COUNT; i++)
8351 9216 sfx_voice[i]=-1;
8352
8353
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 36 times.
288 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8354 252 tunes[i].data = (MIDI*)mididata[i].dat;
8355
8356
2/2
✓ Branch 0 taken 9072 times.
✓ Branch 1 taken 36 times.
9108 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8357 9072 tunes[ZC_MIDI_COUNT+j].data=NULL;
8358
8359 36 master_volume(digi_volume,midi_volume);
8360 36 }
8361
8362 // returns number of voices currently allocated
8363 int32_t sfx_count()
8364 {
8365 int32_t c=0;
8366
8367 for(int32_t i=0; i<WAV_COUNT; i++)
8368 if(sfx_voice[i]!=-1)
8369 ++c;
8370
8371 return c;
8372 }
8373
8374 // clean up finished samples
8375 8067365 void sfx_cleanup()
8376 {
8377
2/2
✓ Branch 0 taken 2065245440 times.
✓ Branch 1 taken 8067365 times.
2073312805 for(int32_t i=0; i<WAV_COUNT; i++)
8378
3/4
✓ Branch 0 taken 633605 times.
✓ Branch 1 taken 2064611835 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 633605 times.
2065879045 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8379 {
8380 633605 deallocate_voice(sfx_voice[i]);
8381 633605 sfx_voice[i]=-1;
8382 633605 }
8383 8067365 }
8384
8385 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8386 // if a voice is already allocated (and/or playing), then it just returns true
8387 // Returns true: voice is allocated
8388 // false: unsuccessful
8389 973721 bool sfx_init(int32_t index)
8390 {
8391 // check index
8392
3/4
✓ Branch 0 taken 702526 times.
✓ Branch 1 taken 271195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 702526 times.
973721 if(index<=0 || index>=WAV_COUNT)
8393 271195 return false;
8394
8395
2/2
✓ Branch 0 taken 68894 times.
✓ Branch 1 taken 633632 times.
702526 if(sfx_voice[index]==-1)
8396 {
8397
2/2
✓ Branch 0 taken 182177 times.
✓ Branch 1 taken 451455 times.
633632 if(sfxdat)
8398 {
8399
1/2
✓ Branch 0 taken 182177 times.
✗ Branch 1 not taken.
182177 if(index<Z35)
8400 {
8401 182177 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8402 182177 }
8403 else
8404 {
8405 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8406 }
8407 182177 }
8408 else
8409 {
8410 451455 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8411 }
8412
8413 633632 voice_set_volume(sfx_voice[index], sfx_volume);
8414 633632 }
8415
8416 702526 return sfx_voice[index] != -1;
8417 973721 }
8418
8419 // plays an sfx sample
8420 829451 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8421 {
8422
2/2
✓ Branch 0 taken 630940 times.
✓ Branch 1 taken 198511 times.
829451 if(!sfx_init(index))
8423 198511 return;
8424
8425 630940 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8426 630940 voice_set_pan(sfx_voice[index],pan);
8427
8428 630940 int32_t pos = voice_get_position(sfx_voice[index]);
8429
8430
2/2
✓ Branch 0 taken 298046 times.
✓ Branch 1 taken 332894 times.
630940 if(restart) voice_set_position(sfx_voice[index],0);
8431
8432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630940 times.
630940 if(pos<=0)
8433 630940 voice_start(sfx_voice[index]);
8434
8435
3/4
✓ Branch 0 taken 332894 times.
✓ Branch 1 taken 298046 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 332894 times.
630940 if (restart && replay_is_debug())
8436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332894 times.
332894 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8437 829451 }
8438
8439 // true if sfx is allocated
8440 35405 bool sfx_allocated(int32_t index)
8441 {
8442
3/4
✓ Branch 0 taken 9407 times.
✓ Branch 1 taken 25998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9407 times.
35405 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8443 }
8444
8445 // start it (in loop mode) if it's not already playing,
8446 // otherwise adjust it to play in loop mode -DD
8447 144270 void cont_sfx(int32_t index)
8448 {
8449
2/2
✓ Branch 0 taken 72684 times.
✓ Branch 1 taken 71586 times.
144270 if(!sfx_init(index))
8450 {
8451 72684 return;
8452 }
8453
8454
1/2
✓ Branch 0 taken 71586 times.
✗ Branch 1 not taken.
71586 if(voice_get_position(sfx_voice[index])<=0)
8455 {
8456 71586 voice_set_position(sfx_voice[index],0);
8457 71586 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8458 71586 voice_start(sfx_voice[index]);
8459 71586 }
8460 else
8461 {
8462 adjust_sfx(index, 128, true);
8463 }
8464 144270 }
8465
8466 // adjust parameters while playing
8467 3961 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8468 {
8469
5/6
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2187 times.
3961 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8470 3947 return;
8471
8472 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8473 14 voice_set_pan(sfx_voice[index],pan);
8474 3961 }
8475
8476 // pauses a voice
8477 1651 void pause_sfx(int32_t index)
8478 {
8479
3/6
✓ Branch 0 taken 1651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1651 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1651 times.
1651 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8480 voice_stop(sfx_voice[index]);
8481 1651 }
8482
8483 // resumes a voice
8484 709 void resume_sfx(int32_t index)
8485 {
8486
3/6
✓ Branch 0 taken 709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 709 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 709 times.
709 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8487 voice_start(sfx_voice[index]);
8488 709 }
8489
8490 // pauses all active voices
8491 319 void pause_all_sfx()
8492 {
8493
2/2
✓ Branch 0 taken 81664 times.
✓ Branch 1 taken 319 times.
81983 for(int32_t i=0; i<WAV_COUNT; i++)
8494
2/2
✓ Branch 0 taken 81663 times.
✓ Branch 1 taken 1 times.
81665 if(sfx_voice[i]!=-1)
8495 1 voice_stop(sfx_voice[i]);
8496 319 }
8497
8498 // resumes all paused voices
8499 306 void resume_all_sfx()
8500 {
8501
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 306 times.
78642 for(int32_t i=0; i<WAV_COUNT; i++)
8502
1/2
✓ Branch 0 taken 78336 times.
✗ Branch 1 not taken.
78336 if(sfx_voice[i]!=-1)
8503 voice_start(sfx_voice[i]);
8504 306 }
8505
8506 // stops an sfx and deallocates the voice
8507 6463094 void stop_sfx(int32_t index)
8508 {
8509
3/4
✓ Branch 0 taken 5321893 times.
✓ Branch 1 taken 1141201 times.
✓ Branch 2 taken 5321893 times.
✗ Branch 3 not taken.
6463094 if(index<=0 || index>=WAV_COUNT)
8510 1141201 return;
8511
8512
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5321880 times.
5321893 if(sfx_voice[index]!=-1)
8513 {
8514 13 deallocate_voice(sfx_voice[index]);
8515 13 sfx_voice[index]=-1;
8516 13 }
8517 6463094 }
8518
8519 // Stops SFX played by Hero's item of the given family
8520 127218 void stop_item_sfx(int32_t family)
8521 {
8522 127218 int32_t id=current_item_id(family);
8523
8524
2/2
✓ Branch 0 taken 126752 times.
✓ Branch 1 taken 466 times.
127218 if(id<0)
8525 126752 return;
8526
8527 466 stop_sfx(itemsbuf[id].usesound);
8528 127218 }
8529
8530 2355 void kill_sfx()
8531 {
8532
2/2
✓ Branch 0 taken 602880 times.
✓ Branch 1 taken 2355 times.
605235 for(int32_t i=0; i<WAV_COUNT; i++)
8533
2/2
✓ Branch 0 taken 602866 times.
✓ Branch 1 taken 14 times.
602894 if(sfx_voice[i]!=-1)
8534 {
8535 14 deallocate_voice(sfx_voice[i]);
8536 14 sfx_voice[i]=-1;
8537 14 }
8538 2355 }
8539
8540 583507 int32_t pan(int32_t x)
8541 {
8542
1/4
✓ Branch 0 taken 583507 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
583507 switch(pan_style)
8543 {
8544 case 0:
8545 return 128;
8546
8547 case 1:
8548 583507 return vbound((x>>1)+68,0,255);
8549
8550 case 2:
8551 return vbound(((x*3)>>2)+36,0,255);
8552 }
8553
8554 return vbound(x,0,255);
8555 583507 }
8556
8557 /*******************************/
8558 /******* Input Handlers ********/
8559 /*******************************/
8560
8561 21712044 bool joybtn(int32_t b)
8562 {
8563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21712044 times.
21712044 if(b == 0)
8564 return false;
8565
8566 21712044 return joy[joystick_index].button[b-1].b !=0;
8567 21712044 }
8568
8569 const char* joybtn_name(int32_t b)
8570 {
8571 if(b == 0)
8572 return "";
8573
8574 return joy[joystick_index].button[b-1].name;
8575 }
8576
8577 int32_t next_press_key();
8578
8579 int32_t next_press_btn()
8580 {
8581 clear_keybuf();
8582 /*bool b[joy[joystick_index].num_buttons+1];
8583
8584 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8585 b[i]=joybtn(i);*/
8586
8587 //first, we need to wait until they're pressing no buttons
8588 for(;;)
8589 {
8590 if(keypressed())
8591 {
8592 switch(readkey()>>8)
8593 {
8594 case KEY_ESC:
8595 return -1;
8596
8597 case KEY_SPACE:
8598 return 0;
8599 }
8600 }
8601
8602 poll_joystick();
8603 bool done = true;
8604
8605 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8606 {
8607 if(joybtn(i)) done = false;
8608 }
8609
8610 if(done) break;
8611 rest(1);
8612 }
8613
8614 //now, we need to wait for them to press any button
8615 for(;;)
8616 {
8617 if(keypressed())
8618 {
8619 switch(readkey()>>8)
8620 {
8621 case KEY_ESC:
8622 return -1;
8623
8624 case KEY_SPACE:
8625 return 0;
8626 }
8627 }
8628
8629 poll_joystick();
8630
8631 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8632 {
8633 if(joybtn(i)) return i;
8634 }
8635 rest(1);
8636 }
8637 }
8638
8639 168097642 static bool rButton(bool &btn, bool &flag)
8640 {
8641
2/2
✓ Branch 0 taken 162219543 times.
✓ Branch 1 taken 5878099 times.
168097642 bool ret = btn && !flag;
8642 168097642 flag = btn;
8643
8644 168097642 return ret;
8645 }
8646 1648122 static bool rButtonPeek(bool btn, bool flag)
8647 {
8648
2/2
✓ Branch 0 taken 1535358 times.
✓ Branch 1 taken 112764 times.
1648122 if(!btn)
8649 {
8650 1535358 return false;
8651 }
8652
2/2
✓ Branch 0 taken 16429 times.
✓ Branch 1 taken 96335 times.
112764 else if(!flag)
8653 {
8654 16429 return true;
8655 }
8656
8657 96335 return false;
8658 1648122 }
8659
8660 // Updated only by keyboard/gamepad.
8661 // If in replay mode, this is set directly by the replay system.
8662 // This should never be read from directly - use control_state instead.
8663 bool raw_control_state[ZC_CONTROL_STATES];
8664
8665 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8666 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8667 // lasts until the next call to load_control_state.
8668 bool control_state[ZC_CONTROL_STATES];
8669 bool disable_control[ZC_CONTROL_STATES];
8670 bool drunk_toggle_state[11];
8671 bool disabledKeys[127];
8672 bool KeyInput[127];
8673 bool KeyPress[127];
8674
8675 bool key_current_frame[127];
8676 bool key_previous_frame[127];
8677
8678 static bool key_system[127];
8679 static bool key_system_previous[127];
8680 static bool key_system_press[127];
8681
8682 bool button_press[ZC_CONTROL_STATES];
8683 bool button_hold[ZC_CONTROL_STATES];
8684
8685 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8686 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8687 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8688 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8689 #define STICK_PRECISION 56 //define your own sensitivity
8690
8691 6800384 void load_control_state()
8692 {
8693 6800384 load_control_called_this_frame = true;
8694
8695
4/4
✓ Branch 0 taken 3929183 times.
✓ Branch 1 taken 2871201 times.
✓ Branch 2 taken 1276431 times.
✓ Branch 3 taken 2652752 times.
6800384 if (replay_get_version() >= 8 && replay_get_version() < 11)
8696 {
8697
2/2
✓ Branch 0 taken 47749536 times.
✓ Branch 1 taken 2652752 times.
50402288 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8698 47749536 down_control_states[i] = raw_control_state[i];
8699 2652752 }
8700
8701
1/2
✓ Branch 0 taken 6800384 times.
✗ Branch 1 not taken.
6800384 if (!replay_is_replaying())
8702 {
8703 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8704 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8705 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8706 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8707 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8708 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8709 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8710 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8711 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8712 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8713 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8714 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8715 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8716 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8717
8718 if(num_joysticks != 0)
8719 {
8720 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8721 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8722 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8723 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8724 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8725 }
8726 else
8727 {
8728 raw_control_state[14] = false;
8729 raw_control_state[15] = false;
8730 raw_control_state[16] = false;
8731 raw_control_state[17] = false;
8732 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8733 }
8734 bool did_bad_cutscene_btn = false;
8735 for(int q = 0; q < 18; ++q)
8736 if(raw_control_state[q] && !active_cutscene.can_button(q))
8737 {
8738 raw_control_state[q] = false;
8739 did_bad_cutscene_btn = true;
8740 }
8741 if(did_bad_cutscene_btn)
8742 active_cutscene.error();
8743 }
8744
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6800381 times.
6800384 if (replay_is_active())
8745 {
8746
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 5785166 times.
6800381 if (replay_get_version() < 3)
8747 1015215 replay_poll();
8748
3/4
✓ Branch 0 taken 5785166 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4023791 times.
✓ Branch 3 taken 1761375 times.
5785166 else if (replay_is_replaying() && replay_get_version() < 6)
8749 1761375 replay_peek_input();
8750
5/6
✓ Branch 0 taken 4023791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929183 times.
✓ Branch 3 taken 94608 times.
✓ Branch 4 taken 1276431 times.
✓ Branch 5 taken 2652752 times.
4023791 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
8751 2652752 replay_peek_input();
8752
2/2
✓ Branch 0 taken 5695624 times.
✓ Branch 1 taken 1104757 times.
6800381 if (replay_get_version() == 8)
8753 1104757 update_keys();
8754 6800381 }
8755
8756 // Some test replay files were made before a serious input bug was fixed, so instead
8757 // of re-doing them or tossing them out, just check for that zplay version.
8758
3/4
✓ Branch 0 taken 6800378 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 6678478 times.
6800384 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8759
2/2
✓ Branch 0 taken 122406804 times.
✓ Branch 1 taken 6800378 times.
129207182 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8760 {
8761 122406804 control_state[i] = raw_control_state[i];
8762
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 72919494 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
122406804 if (botched_input && !control_state[i])
8763 47077142 down_control_states[i] = false;
8764 122406804 }
8765
8766 6800378 button_press[0]=rButton(control_state[0],button_hold[0]);
8767 6800378 button_press[1]=rButton(control_state[1],button_hold[1]);
8768 6800378 button_press[2]=rButton(control_state[2],button_hold[2]);
8769 6800378 button_press[3]=rButton(control_state[3],button_hold[3]);
8770 6800378 button_press[4]=rButton(control_state[4],button_hold[4]);
8771 6800378 button_press[5]=rButton(control_state[5],button_hold[5]);
8772 6800378 button_press[6]=rButton(control_state[6],button_hold[6]);
8773 6800378 button_press[7]=rButton(control_state[7],button_hold[7]);
8774 6800378 button_press[8]=rButton(control_state[8],button_hold[8]);
8775 6800378 button_press[9]=rButton(control_state[9],button_hold[9]);
8776 6800378 button_press[10]=rButton(control_state[10],button_hold[10]);
8777 6800378 button_press[11]=rButton(control_state[11],button_hold[11]);
8778 6800378 button_press[12]=rButton(control_state[12],button_hold[12]);
8779 6800378 button_press[13]=rButton(control_state[13],button_hold[13]);
8780 6800378 button_press[14]=rButton(control_state[14],button_hold[14]);
8781 6800378 button_press[15]=rButton(control_state[15],button_hold[15]);
8782 6800378 button_press[16]=rButton(control_state[16],button_hold[16]);
8783 6800378 button_press[17]=rButton(control_state[17],button_hold[17]);
8784 6800378 }
8785
8786 // Returns true if any game key is pressed. This is needed because keypressed()
8787 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8788 35281407 bool zc_key_pressed()
8789 //may also need to use zc_getrawkey
8790 {
8791
7/10
✓ Branch 0 taken 28580864 times.
✓ Branch 1 taken 6700543 times.
✓ Branch 2 taken 6700543 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6700543 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5616890 times.
✓ Branch 7 taken 5616890 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2127187 times.
37408594 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8792
4/6
✓ Branch 0 taken 5616890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5616890 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4253377 times.
✓ Branch 5 taken 4253377 times.
5616890 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8793
4/6
✓ Branch 0 taken 4253377 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4253377 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2746392 times.
✓ Branch 5 taken 2746392 times.
4253377 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8794
4/6
✓ Branch 0 taken 2746392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2746392 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2380525 times.
✓ Branch 5 taken 2380525 times.
2746392 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8795
1/2
✓ Branch 0 taken 2380525 times.
✗ Branch 1 not taken.
2380525 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8796
3/4
✓ Branch 0 taken 2264784 times.
✓ Branch 1 taken 115741 times.
✓ Branch 2 taken 2264784 times.
✗ Branch 3 not taken.
2380525 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8797
3/4
✓ Branch 0 taken 2156879 times.
✓ Branch 1 taken 107905 times.
✓ Branch 2 taken 2156879 times.
✗ Branch 3 not taken.
2264784 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8798
3/4
✓ Branch 0 taken 2142388 times.
✓ Branch 1 taken 14491 times.
✓ Branch 2 taken 2142388 times.
✗ Branch 3 not taken.
2156879 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8799
3/4
✓ Branch 0 taken 2129810 times.
✓ Branch 1 taken 12578 times.
✓ Branch 2 taken 2129810 times.
✗ Branch 3 not taken.
2142388 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8800
3/4
✓ Branch 0 taken 2128066 times.
✓ Branch 1 taken 1744 times.
✓ Branch 2 taken 2128066 times.
✗ Branch 3 not taken.
2129810 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8801
3/4
✓ Branch 0 taken 2127993 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 2127993 times.
✗ Branch 3 not taken.
2128066 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8802
3/4
✓ Branch 0 taken 2127206 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 2127206 times.
✗ Branch 3 not taken.
2127993 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8803
2/4
✓ Branch 0 taken 2127206 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2127206 times.
✗ Branch 3 not taken.
2127206 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8804
2/2
✓ Branch 0 taken 2127187 times.
✓ Branch 1 taken 19 times.
2127206 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8805 63148588 return true;
8806
8807 2127187 return false;
8808 8114047 }
8809
8810 133504082 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8811 {
8812 133504082 bool ret = false, drunkstate = false;
8813 133504082 bool* flag = &down_control_states[btn];
8814
2/7
✓ Branch 0 taken 125381543 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 8122539 times.
133504082 switch(btn)
8815 {
8816 case btnF12:
8817 ret = zc_getkey(KEY_F12, ignoreDisable);
8818 eatEntirely = false;
8819 break;
8820 case btnF11:
8821 ret = zc_getkey(KEY_F11, ignoreDisable);
8822 eatEntirely = false;
8823 break;
8824 case btnF5:
8825 ret = zc_getkey(KEY_F5, ignoreDisable);
8826 eatEntirely = false;
8827 break;
8828 case btnQ:
8829 ret = zc_getkey(KEY_Q, ignoreDisable);
8830 eatEntirely = false;
8831 break;
8832 case btnI:
8833 ret = zc_getkey(KEY_I, ignoreDisable);
8834 eatEntirely = false;
8835 break;
8836 case btnM:
8837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8122539 times.
8122539 if(FFCore.kb_typing_mode) return false;
8838 8122539 ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8839 8122539 eatEntirely = false;
8840 8122539 break;
8841 default: //control_state[] index
8842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125381543 times.
125381543 if(FFCore.kb_typing_mode) return false;
8843
5/6
✓ Branch 0 taken 124934356 times.
✓ Branch 1 taken 447187 times.
✓ Branch 2 taken 2023636 times.
✓ Branch 3 taken 122910720 times.
✓ Branch 4 taken 2023636 times.
✗ Branch 5 not taken.
125381543 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8844
2/2
✓ Branch 0 taken 6779685 times.
✓ Branch 1 taken 118601858 times.
125381543 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8845
4/4
✓ Branch 0 taken 113026809 times.
✓ Branch 1 taken 12354734 times.
✓ Branch 2 taken 5041 times.
✓ Branch 3 taken 12349693 times.
137736277 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8846 125381543 }
8847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133504082 times.
133504082 assert(flag);
8848
2/2
✓ Branch 0 taken 86165122 times.
✓ Branch 1 taken 47338960 times.
133504082 if(press)
8849 {
8850
2/2
✓ Branch 0 taken 1648122 times.
✓ Branch 1 taken 45690838 times.
47338960 if(peek)
8851 1648122 ret = rButtonPeek(ret, *flag);
8852 45690838 else ret = rButton(ret, *flag);
8853 47338960 }
8854
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133504082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133504082 if(eatEntirely && ret) control_state[btn] = false;
8855
3/4
✓ Branch 0 taken 101024901 times.
✓ Branch 1 taken 32479181 times.
✓ Branch 2 taken 101024901 times.
✗ Branch 3 not taken.
133504082 if(drunk && drunkstate) ret = !ret;
8856 133504082 return ret;
8857 133504082 }
8858
8859 6552523 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8860 {
8861 6552523 byte ret = 0;
8862
2/2
✓ Branch 0 taken 4902311 times.
✓ Branch 1 taken 1650212 times.
6552523 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8863
2/2
✓ Branch 0 taken 6551961 times.
✓ Branch 1 taken 562 times.
6552523 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8864
2/2
✓ Branch 0 taken 6552086 times.
✓ Branch 1 taken 437 times.
6552523 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8865
2/2
✓ Branch 0 taken 6552086 times.
✓ Branch 1 taken 437 times.
6552523 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8866
2/2
✓ Branch 0 taken 6552086 times.
✓ Branch 1 taken 437 times.
6552523 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8867
2/2
✓ Branch 0 taken 6552086 times.
✓ Branch 1 taken 437 times.
6552523 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8868
2/2
✓ Branch 0 taken 6552086 times.
✓ Branch 1 taken 437 times.
6552523 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8869
2/2
✓ Branch 0 taken 6552086 times.
✓ Branch 1 taken 437 times.
6552523 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8870 6552523 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8871 }
8872
8873 1114 byte checkIntBtnVal(byte intbtn, byte vals)
8874 {
8875 1114 return intbtn&vals;
8876 }
8877
8878 1575034 bool Up()
8879 {
8880 1575034 return getInput(btnUp);
8881 }
8882 99232 bool Down()
8883 {
8884 99232 return getInput(btnDown);
8885 }
8886 190328 bool Left()
8887 {
8888 190328 return getInput(btnLeft);
8889 }
8890 213301 bool Right()
8891 {
8892 213301 return getInput(btnRight);
8893 }
8894 112761 bool cAbtn()
8895 {
8896 112761 return getInput(btnA);
8897 }
8898 1333347 bool cBbtn()
8899 {
8900 1333347 return getInput(btnB);
8901 }
8902 bool cSbtn()
8903 {
8904 return getInput(btnS);
8905 }
8906 46682 bool cLbtn()
8907 {
8908 46682 return getInput(btnL);
8909 }
8910 46682 bool cRbtn()
8911 {
8912 46682 return getInput(btnR);
8913 }
8914 bool cPbtn()
8915 {
8916 return getInput(btnP);
8917 }
8918 bool cEx1btn()
8919 {
8920 return getInput(btnEx1);
8921 }
8922 bool cEx2btn()
8923 {
8924 return getInput(btnEx2);
8925 }
8926 bool cEx3btn()
8927 {
8928 return getInput(btnEx3);
8929 }
8930 bool cEx4btn()
8931 {
8932 return getInput(btnEx4);
8933 }
8934 bool AxisUp()
8935 {
8936 return getInput(btnAxisUp);
8937 }
8938 bool AxisDown()
8939 {
8940 return getInput(btnAxisDown);
8941 }
8942 bool AxisLeft()
8943 {
8944 return getInput(btnAxisLeft);
8945 }
8946 bool AxisRight()
8947 {
8948 return getInput(btnAxisRight);
8949 }
8950
8951 bool cMbtn()
8952 {
8953 return getInput(btnM);
8954 }
8955 bool cF12()
8956 {
8957 return getInput(btnF12);
8958 }
8959 bool cF11()
8960 {
8961 return getInput(btnF11);
8962 }
8963 bool cF5()
8964 {
8965 return getInput(btnF5);
8966 }
8967 bool cQ()
8968 {
8969 return getInput(btnQ);
8970 }
8971 bool cI()
8972 {
8973 return getInput(btnI);
8974 }
8975
8976 127703 bool rUp()
8977 {
8978 127703 return getInput(btnUp, true);
8979 }
8980 127609 bool rDown()
8981 {
8982 127609 return getInput(btnDown, true);
8983 }
8984 127557 bool rLeft()
8985 {
8986 127557 return getInput(btnLeft, true);
8987 }
8988 127093 bool rRight()
8989 {
8990 127093 return getInput(btnRight, true);
8991 }
8992 2987 bool rAbtn()
8993 {
8994 2987 return getInput(btnA, true);
8995 }
8996 128823 bool rBbtn()
8997 {
8998 128823 return getInput(btnB, true);
8999 }
9000 6536010 bool rSbtn()
9001 {
9002 6536010 return getInput(btnS, true);
9003 }
9004 8114047 bool rMbtn()
9005 {
9006 8114047 return getInput(btnM, true);
9007 }
9008 126885 bool rLbtn()
9009 {
9010 126885 return getInput(btnL, true);
9011 }
9012 126880 bool rRbtn()
9013 {
9014 126880 return getInput(btnR, true);
9015 }
9016 6453183 bool rPbtn()
9017 {
9018 6453183 return getInput(btnP, true);
9019 }
9020 bool rEx1btn()
9021 {
9022 return getInput(btnEx1, true);
9023 }
9024 bool rEx2btn()
9025 {
9026 return getInput(btnEx2, true);
9027 }
9028 137531 bool rEx3btn()
9029 {
9030 137531 return getInput(btnEx3, true);
9031 }
9032 137531 bool rEx4btn()
9033 {
9034 137531 return getInput(btnEx4, true);
9035 }
9036 bool rAxisUp()
9037 {
9038 return getInput(btnAxisUp, true);
9039 }
9040 bool rAxisDown()
9041 {
9042 return getInput(btnAxisDown, true);
9043 }
9044 bool rAxisLeft()
9045 {
9046 return getInput(btnAxisLeft, true);
9047 }
9048 bool rAxisRight()
9049 {
9050 return getInput(btnAxisRight, true);
9051 }
9052
9053 bool rF11()
9054 {
9055 return getInput(btnF11, true);
9056 }
9057 bool rQ()
9058 {
9059 return getInput(btnQ, true);
9060 }
9061 bool rI()
9062 {
9063 return getInput(btnI, true);
9064 }
9065
9066 16356863 bool DrunkUp()
9067 {
9068 16356863 return getInput(btnUp, false, true);
9069 }
9070 15232309 bool DrunkDown()
9071 {
9072 15232309 return getInput(btnDown, false, true);
9073 }
9074 9582674 bool DrunkLeft()
9075 {
9076 9582674 return getInput(btnLeft, false, true);
9077 }
9078 8319696 bool DrunkRight()
9079 {
9080 8319696 return getInput(btnRight, false, true);
9081 }
9082 7119805 bool DrunkcAbtn()
9083 {
9084 7119805 return getInput(btnA, false, true);
9085 }
9086 6991784 bool DrunkcBbtn()
9087 {
9088 6991784 return getInput(btnB, false, true);
9089 }
9090 6406154 bool DrunkcEx1btn()
9091 {
9092 6406154 return getInput(btnEx1, false, true);
9093 }
9094 6406174 bool DrunkcEx2btn()
9095 {
9096 6406174 return getInput(btnEx2, false, true);
9097 }
9098 bool DrunkcSbtn()
9099 {
9100 return getInput(btnS, false, true);
9101 }
9102 bool DrunkcMbtn()
9103 {
9104 return getInput(btnM, false, true);
9105 }
9106 bool DrunkcLbtn()
9107 {
9108 return getInput(btnL, false, true);
9109 }
9110 bool DrunkcRbtn()
9111 {
9112 return getInput(btnR, false, true);
9113 }
9114 bool DrunkcPbtn()
9115 {
9116 return getInput(btnP, false, true);
9117 }
9118
9119 bool DrunkrUp()
9120 {
9121 return getInput(btnUp, true, true);
9122 }
9123 bool DrunkrDown()
9124 {
9125 return getInput(btnDown, true, true);
9126 }
9127 bool DrunkrLeft()
9128 {
9129 return getInput(btnLeft, true, true);
9130 }
9131 bool DrunkrRight()
9132 {
9133 return getInput(btnRight, true, true);
9134 }
9135 5364661 bool DrunkrAbtn()
9136 {
9137 5364661 return getInput(btnA, true, true);
9138 }
9139 5380262 bool DrunkrBbtn()
9140 {
9141 5380262 return getInput(btnB, true, true);
9142 }
9143 71669 bool DrunkrEx1btn()
9144 {
9145 71669 return getInput(btnEx1, true, true);
9146 }
9147 71662 bool DrunkrEx2btn()
9148 {
9149 71662 return getInput(btnEx2, true, true);
9150 }
9151 bool DrunkrEx3btn()
9152 {
9153 return getInput(btnEx3, true, true);
9154 }
9155 bool DrunkrEx4btn()
9156 {
9157 return getInput(btnEx4, true, true);
9158 }
9159 bool DrunkrSbtn()
9160 {
9161 return getInput(btnS, true, true);
9162 }
9163 bool DrunkrMbtn()
9164 {
9165 return getInput(btnM, true, true);
9166 }
9167 6035587 bool DrunkrLbtn()
9168 {
9169 6035587 return getInput(btnL, true, true);
9170 }
9171 6032205 bool DrunkrRbtn()
9172 {
9173 6032205 return getInput(btnR, true, true);
9174 }
9175 bool DrunkrPbtn()
9176 {
9177 return getInput(btnP, true, true);
9178 }
9179
9180 8492 void eat_buttons()
9181 {
9182 8492 getInput(btnA, true, false, true);
9183 8492 getInput(btnB, true, false, true);
9184 8492 getInput(btnS, true, false, true);
9185 8492 getInput(btnM, true, false, true);
9186 8492 getInput(btnL, true, false, true);
9187 8492 getInput(btnR, true, false, true);
9188 8492 getInput(btnP, true, false, true);
9189 8492 getInput(btnEx1, true, false, true);
9190 8492 getInput(btnEx2, true, false, true);
9191 8492 getInput(btnEx3, true, false, true);
9192 8492 getInput(btnEx4, true, false, true);
9193 8492 }
9194
9195 // Is true for the _first frame_ of a key press.
9196 // But! it is possible that a script manually sets the value of KeyPress,
9197 // in which case it will be restored to the "true" value based on `key_current_frame`
9198 // and `key_previous_frame` on the next frame.
9199 13 bool zc_readkey(int32_t k, bool ignoreDisable)
9200 {
9201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(ignoreDisable) return KeyPress[k];
9202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 switch(k)
9203 {
9204 case KEY_F7:
9205 case KEY_F8:
9206 case KEY_F9:
9207 return KeyPress[k];
9208
9209 default:
9210
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 return KeyPress[k] && !disabledKeys[k];
9211 }
9212 13 }
9213
9214 // Is true for _every frame_ a key is held down.
9215 // But! it is possible that a script manually sets the value of KeyInput,
9216 // in which case it will be restored to the "true" value based on `key_current_frame`
9217 // on the next frame.
9218 bool zc_getkey(int32_t k, bool ignoreDisable)
9219 {
9220 if(ignoreDisable) return KeyInput[k];
9221 switch(k)
9222 {
9223 case KEY_F7:
9224 case KEY_F8:
9225 case KEY_F9:
9226 return KeyInput[k];
9227
9228 default:
9229 return KeyInput[k] && !disabledKeys[k];
9230 }
9231 }
9232
9233 // Reads (and then clears) the current frame key state directly.
9234 // Scripts can also modify `key_current_frame`.
9235 198 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9236 {
9237
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 196 times.
198 if(zc_getrawkey(k, ignoreDisable))
9238 {
9239 2 _key[k]=key[k]=key_current_frame[k]=0;
9240 2 return true;
9241 }
9242 196 _key[k]=key[k]=key_current_frame[k]=0;
9243 196 return false;
9244 198 }
9245
9246 // Reads the current frame key state directly.
9247 // Scripts can also modify `key_current_frame`.
9248 55138843 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9249 {
9250
2/2
✓ Branch 0 taken 47024770 times.
✓ Branch 1 taken 8114073 times.
55138843 if(ignoreDisable) return key_current_frame[k];
9251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8114073 times.
8114073 switch(k)
9252 {
9253 case KEY_F7:
9254 case KEY_F8:
9255 case KEY_F9:
9256 return key_current_frame[k];
9257
9258 default:
9259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8114073 times.
8114073 return key_current_frame[k] && !disabledKeys[k];
9260 }
9261 55138843 }
9262
9263 // Only used for a handful of keys, like tilde and Function keys.
9264 // This state is never read within the game.
9265 // It exists so that all keyboard input still functions during replay,
9266 // without inadvertently doing things like toggling throttling if the player
9267 // presses ~
9268 16228191 bool zc_get_system_key(int32_t k)
9269 {
9270 16228191 return key_system[k];
9271 }
9272
9273 // True for the _first_ frame of a key press.
9274 73026423 bool zc_read_system_key(int32_t k)
9275 {
9276 73026423 return key_system_press[k];
9277 }
9278
9279 1030483969 bool is_system_key(int32_t k)
9280 {
9281
2/2
✓ Branch 0 taken 957457546 times.
✓ Branch 1 taken 73026423 times.
1030483969 switch (k)
9282 {
9283 case KEY_BACKQUOTE:
9284 case KEY_CLOSEBRACE:
9285 case KEY_END:
9286 case KEY_HOME:
9287 case KEY_OPENBRACE:
9288 case KEY_PGDN:
9289 case KEY_PGUP:
9290 case KEY_TAB:
9291 case KEY_TILDE:
9292 73026423 return true;
9293 }
9294 957457546 return is_Fkey(k);
9295 1030483969 }
9296
9297 8114047 void update_system_keys()
9298 {
9299
2/2
✓ Branch 0 taken 1030483969 times.
✓ Branch 1 taken 8114047 times.
1038598016 for (int32_t q = 0; q < 127; ++q)
9300 {
9301
2/2
✓ Branch 0 taken 170394987 times.
✓ Branch 1 taken 860088982 times.
1030483969 if (!is_system_key(q))
9302 860088982 continue;
9303
9304 170394987 key_system[q] = key[q];
9305
1/2
✓ Branch 0 taken 170394987 times.
✗ Branch 1 not taken.
170394987 key_system_press[q] = key_system[q] && !key_system_previous[q];
9306 170394987 key_system_previous[q] = key_system[q];
9307 170394987 }
9308 8114047 }
9309
9310 9218804 void update_keys()
9311 {
9312
2/2
✓ Branch 0 taken 1170788108 times.
✓ Branch 1 taken 9218804 times.
1180006912 for (int32_t q = 0; q < 127; ++q)
9313 {
9314 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9315
1/2
✓ Branch 0 taken 1170788108 times.
✗ Branch 1 not taken.
1170788108 if (!replay_is_replaying())
9316 key_current_frame[q] = key[q];
9317
9318
2/2
✓ Branch 0 taken 1162143646 times.
✓ Branch 1 taken 8644462 times.
1170788108 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9319 1170788108 KeyInput[q] = key_current_frame[q];
9320 1170788108 key_previous_frame[q] = key_current_frame[q];
9321 1170788108 }
9322 9218804 }
9323
9324 bool zc_disablekey(int32_t k, bool val)
9325 {
9326 switch(k)
9327 {
9328 case KEY_F7:
9329 case KEY_F8:
9330 case KEY_F9:
9331 return false;
9332
9333 default:
9334 disabledKeys[k] = val;
9335 return true;
9336 }
9337 }
9338
9339 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9340 {
9341 timer=timer;
9342 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9343 }
9344